Hi cricket, The $this->Stock->id is set correctly. And the SQL is working perfectly, i can get the correct number of records (which 3 of them: 4, 7, 14)
On Apr 27, 1:53 am, cricket <[email protected]> wrote: > Is $this->Stock->id set to something? What does the SQL look like? Set > debug to 2 to see it. > > > > On Mon, Apr 25, 2011 at 1:25 PM, jackgoh <[email protected]> wrote: > > Hi, > > > I am facing some problem when deal with a realtionship tables, the > > record is not display : > > > // in Stock model: > > var $hasAndBelongsToMany = array( > > 'Category' => array( > > 'className' => 'Category', > > 'joinTable' => 'category', > > 'foreignKey' => 'stock_id', > > 'associationForeignKey' => category_id', > > 'with' => 'StockCategory', > > ), > > ); > > > // in Stock controller: > > $selectedRecord = $this->Stock->StockCategory->find('list', > > array( 'fields'=>array('stock_id','category_id'), > > 'conditions'=>array('stock_id='.$this->Stock->id) ) ); > > $this->set(compact('selectedRecord')); > > > I try to copy the SQL by using debug() to phpmysql, and i get 3 lines > > of records. but when i try to PRINT_R the $selectedRecord, i can only > > get 1 record, example: > > > Array > > ( > > [1] => 4 > > ) > > > Suppose the result have to be : > > > Array > > ( > > [1] => 4 > > [1] => 7 > > [1] => 14 > > ) > > > Values : 4,7,14 are category_id, [1] is stock_id. There is a table > > call "category" to store all the category name. > > > Please point out whats wrong to my code or logic?? > > > Thanks > > > Best Regards. > > > -- > > Our newest site for the community: CakePHP Video > > Tutorialshttp://tv.cakephp.org > > Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help > > others with their CakePHP related questions. > > > To unsubscribe from this group, send email to > > [email protected] For more options, visit this group > > athttp://groups.google.com/group/cake-php- Hide quoted text - > > - Show quoted text - -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php
