How to use LIKE OR operator using cakephp & mysql

前端 未结 3 1932
后悔当初
后悔当初 2021-01-12 01:31

I am new to cakephp & don\'t know what is the syntax to use LIKE & OR operator in cakephp with mysql.

Can anyone help me? T

3条回答
  •  南方客
    南方客 (楼主)
    2021-01-12 02:10

    you can use: for "like"

    $this->Post->find("all",array('condition'=>array('Author LIKE'=>"ad%")));
    

    above query will give You the data from table posts where author name starts with "ad".

    for "OR"

    $this->Post->find("all",array('condition'=>array("OR"=>array('Author LIKE'=>"ad%",'Post LIKE'=>"bo%"))));
    

    above query will give You the data from table posts where author name starts with "ad" OR Post starts with "bo".

提交回复
热议问题