php - display data from two tables using inner join in cakephp -
i using cakephp. have 2 tables names , gender. want display names gender. names displaying male only. there female in gender not selected. code below.
$this->loadmodel("names"); $modelmerge = $this->names->bindmodel(array ( 'belongsto' => array ( 'genders' => array ( 'foreignkey' => false, 'conditions' => array ( 'genders.id = names.genders_id' ) ) ) )); $this->set("names", $this->names->find('all', array('limit' => 10)));
this select names.genders_id = 1 rest of not selected. please guide.
i'm assuming either on old version of cakephp or using bad naming conventions.
$modelmerge = $this->names->bindmodel( array( 'belongsto' => array( 'genders' => array( 'classname' => 'genders', 'foreignkey' => genders_id ) ) ) ); $names = $this->names->find('all', array( 'limit' => 10, 'recursive' => 0 )); $this->set("names", $names);
the following work. however, suggest read on naming models/db columns, model associations , containable behavior. links version 2.x think might on 1.3 or earlier refer old book.
Comments
Post a Comment