Radicore Forum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » RADICORE » How To » How to filter by a parent field in a link1 transaction
Re: How to filter by a parent field in a link1 transaction [message #1490 is a reply to message #1488] Wed, 16 July 2008 16:30 Go to previous messageGo to previous message
AJM is currently offline  AJM
Messages: 2361
Registered: April 2006
Location: Surrey, UK
Senior Member
It is a simple question. The LINK1 pattern contains 2 tables (entities) called $dbouter and $dblink, so in which _cm_pre_getData() method are you trying to modify the 'where' string - in $dbouter or $dblink?

It sounds like you have 'team' as $dbouter and 'team_player_xref' as $dblink, and $dblink then joins with 'player'.

By default the 'where' string which is extracted from $dbouter and passed to $dblink is the primary key of the database row in $dbouter. If you wish to pass an extra value to $dblink called 'date' then the first step you need to take is to obtain a value for 'date'. Your attempt to use the _cm_pre_getData() method in $dbouter is totally wrong as you haven't even read the 'team' record yet. You can either put code in the _cm_post_getData() method to read the 'category' table AFTER you have obtained a value for category_id from the 'team' record, or you can read the 'category' table AT THE SAME TIME as reading the 'team' table by building an sql SELECT statement along the lines of
SELECT ... FROM team LEFT JOIN category USING (category_id)

You can have the framework do this automatically for you by modifying the relationship between 'category' and 'team' to specify which fields are to be returned from the 'category' table whenever the 'team' table is read. Please refer to http://www.tonymarston.net/php-mysql/menuguide/dict_relation ship(upd).html and http://www.tonymarston.net/php-mysql/data-dictionary.html#sq l.joins for details.

To have the value for 'date' included in the 'where' string which is extracted from $dbouter and passed to $dblink you need to make use of the _cm_filterWhere() method.

As the value for 'date' is obtained from the 'category' table where 'category_id' is obtained from the 'team' table, you could even put your code in the _cm_pre_getData() method of $dblink before you build the sql SELECT statement.

Once you have got this far you need to look at the sql SELECT statement which is issued by $dblink - either by stepping through with your debugger or using the facilities described in http://www.tonymarston.net/php-mysql/infrastructure-faq.html #faq51. Then you need to identify what changes need to be made to this statement in order to achieve the result that you want, then make the changes as described in either http://www.tonymarston.net/php-mysql/infrastructure-faq.html #faq08 or http://www.tonymarston.net/php-mysql/infrastructure-faq.html #faq84.


 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: override noedit on foreign field in multi2
Next Topic: How ro remove the 'page created in' message
Goto Forum:
  


Current Time: Thu Sep 12 06:35:10 EDT 2024

Total time taken to generate the page: 0.01053 seconds