【DooPHP】db->findで検索(SELECT)

db->findを使用して、検索するときのメモ。

■パターン1 Whereを個別に記述する方法。
このパターンは条件を指定する際に、見やすく書くことができますが、
条件の追加は全てANDになってしまいます。

Doo::loadModel(‘User’);
$user = new User;
$user->login_id = ‘aaa’;
$result = $this->db()->find( $user ,array(‘order by’=>’id’));

■パターン2 Whereをまとめて記述する方法。
このパターンは条件を直接続けて書く事ができます。
条件が多い場合は、見づらくなってしまいますが、
OR構文や複雑な条件指定の際に使用できます。

Doo::loadModel(‘User’);
$user = new User;
$result = $this->db()->find( $user ,array(‘where’=>’login_id=”aaa”‘,’order by’=>’id’));

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x