Fetch multiple table value in cakephp.pdf
Transcript of Fetch multiple table value in cakephp.pdf
Fetch multiple table value in cakephp
Asked by Jaiprakash Singh on 2013-12-24T03:20:48-05:00I using the code for fetching the data in two tables in cakephp. var $belongsTo = array( 'Menuitem' => array( 'className' => 'Menuitem', 'foreignKey' =>'menu' ) ); menu is the index key in both tables but it is showing the first table data showing proper but insecond table showing null values. **'Menu' => array( 'id' => '1', 'menuName' => 'awefawef', 'restID' => '2', 'menu' => '41066', 'status' => '0' ), 'Menuitem' => array( 'id' => null, 'menuID' => null, 'sectionID' => null, 'itemName'=> null, 'itemPrice' => null, 'itemDescription' => null, 'menu' => null, 'status' => null ) ), (int) 1 =>array( 'Menu' => array( 'id' => '2', 'menuName' => 'awefawef', 'restID' => '2', 'menu' => '17717', 'status' => '0' ), 'Menuitem' => array( 'id' => null, 'menuID' => null, 'sectionID' => null, 'itemName'=> null, 'itemPrice' => null, 'itemDescription' => null, 'menu' => null, 'status' => null )** Pleaseadvice
Archives
Technology Questions and AnswersProgrammers Questions and AnswersDec 24th, 2013 ArchivesWeek 52, 2013 ArchivesDecember, 2013 Archives
Tags
Cakephp 2.3
Best Answer
Answered by Anubhav on 2013-12-24T04:32:10-05:00In cakePHP the above join will not work because you are NOT following name conventions. So in your Menu model create one function and write below code: $options = array( 'conditions' => array(**YOUR CONDITIONS**), 'joins' => array( array( 'alias'=> 'Menuitem', 'table' => ‘menuitems’, 'type' => 'LEFT', 'conditions' => array( 'Menuitem.menuID = Menu.id', ), ) ), 'fields' => array(“**Your Fields**―) ); $returnData =$this->find('all',$options); Thanks
View Online
http://www.rqna.net/qna/qxvysy-fetch-multiple-table-value-in-cakephp.html
Rqna Page 1/1