Blogブログ

Day: November 19, 2013

cakephp memo : basic sql

・普通のSQL。アソシエーションがあるテーブルの値も自動で取得出来る。 fields, conditionsでselect, where. public function index(){ $users = $this->User->find(‘all’, array( ‘fields’ => array(‘*’), ‘conditions’ => array(‘group_id =’ => ‘2’), )); $this->set(‘users’, $users); } ・inner joinを使う場合。 public function index(){ $users = $this->User->find(‘all’, array( ‘fields’ => array(‘*’), ‘conditions’ => array(‘group_id =’ => ‘2’),             “joins” => array(                              array(“type” => ‘INNER’,                                    “table” => ‘somethings’,                                    “alias” => ‘Something’,                                    “conditions” […]