https://github.com/CakeDC/search
Ì Search PluginÌà¾ð©éÆA orConditions() Ìæ¤È\bhð©ªÅÆAu¯ï¿½ï¿½L[[hÅ¡tB[hðõÅ«¿áÁ½è·éævÆï¿½ï¿½Ä èÜ·B
f.php ÌÉA
public $filterArgs = array(
'filter' => array('type' => 'query', 'method' => 'orConditions'),
);
Ʃ��ÄA
public function orConditions($data = array()) {
$filter = $data['filter'];
$cond = array(
'OR' => array(
$this->alias . '.title LIKE' => '%' . $filter . '%',
$this->alias . '.body LIKE' => '%' . $filter . '%',
));
return $cond;
}
Æ��¤R[hÉU�}µÄâêÎAtitletB[hÆbodytB[hð¼ûõÅ«¿á��ܷæAÆB
Åà�}êð»ÌÜÜf¼Ég¤ÆAõÚª¡ éÆ«ÉâèÉÈÁĵÜ��ܷB
¹Á©TvÌWóÔÅÍA
SQLÌNGªA
@~~~ WHERE f.tB[hA='A' AND f.tB[hB='B' AND f.tB[hC='C'
Ìæ¤ÉièÝÉÈÁÄ��éÌÉAãLð»ÌÜÜÂÁ�}ÞÆA
@~~~ WHERE f.tB[hA='A' OR f.title='B' OR f.body='B' AND f.tB[hC='C'
Æ©ÉÈÁĵܤñÅ·B
�}êÍg¦È��I
ÅA�}êÌðôÅ·ªA¿åÁÆl¦éÆv��«ܷB
ºLÌæ¤É"«¿ñÆ"ÝèµÜµå¤B
public function orConditions($data = array()) {
$filter = $data['filter'];
$cond = array(
'AND'=>array(
'OR' => array(
$this->alias . '.title LIKE' => '%' . $filter . '%',
$this->alias . '.body LIKE' => '%' . $filter . '%',
)
));
return $cond;
}
�}¤·é¾¯ÅA
@~~~ WHERE f.tB[hA='A' AND (f.title='B' OR f.body='B') AND f.tB[hC='C'
Æ��¤SQLÉÈèÜ·B