2014”N01ŒŽ29“ú

Search Plugin‚ŁAorConditions() ‚Ý‚½‚��‚È‚Ì‚ðŽg‚��‚È‚ª‚瓯Žž‚ɍi‚荞‚Þ

‚‚��‚Å‚É‚à‚¤‚ЂƂ‘‚��‚�N‚«‚Ü‚·B

https://github.com/CakeDC/search
‚Ì Search Plugin‚Ìà–¾‚ðŒ©‚é‚ƁA orConditions() ‚̂悤‚ȃƒ\ƒbƒh‚ðŽ©•ª‚ŏ‘‚­‚ƁAu“¯‚��ƒL[ƒ[ƒh‚Å•¡”ƒtƒB[ƒ‹ƒ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“�}‚µ‚Ä‚â‚ê‚΁AtitleƒtƒB[ƒ‹ƒh‚ÆbodyƒtƒB[ƒ‹ƒh‚𗼕ûŒŸõ‚Å‚«‚¿‚á‚��‚Ü‚·‚æA‚ƁB
‚Å‚à‚�}‚ê‚ð‚»‚Ì‚Ü‚Ü‘f’¼‚ÉŽg‚¤‚ƁAŒŸõ€–Ú‚ª•¡”‚ ‚é‚Æ‚«‚É–â‘è‚É‚È‚Á‚Ä‚µ‚܂��‚Ü‚·B

‚¹‚Á‚©‚­ƒTƒ“ƒvƒ‹‚Ì•W€ó‘Ԃł́A
SQL‚̃NƒGƒŠ‚ªA
@~~~ WHERE ƒ‚ƒfƒ‹.ƒtƒB[ƒ‹ƒhA='A' AND ƒ‚ƒfƒ‹.ƒtƒB[ƒ‹ƒhB='B' AND ƒ‚ƒfƒ‹.ƒtƒB[ƒ‹ƒhC='C'
‚̂悤‚ɍi‚荞‚Ý‚É‚È‚Á‚��‚é‚̂ɁAã‹L‚ð‚»‚Ì‚Ü‚Ü‚Â‚Á‚�}‚ނƁA
@~~~ WHERE ƒ‚ƒfƒ‹.ƒtƒB[ƒ‹ƒhA='A' OR ƒ‚ƒfƒ‹.title='B' OR ƒ‚ƒfƒ‹.body='B' AND ƒ‚ƒfƒ‹.ƒtƒB[ƒ‹ƒ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ƒ‹.ƒtƒB[ƒ‹ƒhA='A' AND (ƒ‚ƒfƒ‹.title='B' OR ƒ‚ƒfƒ‹.body='B') AND ƒ‚ƒfƒ‹.ƒtƒB[ƒ‹ƒhC='C'

‚Ƃ��‚¤SQL‚É‚È‚è‚Ü‚·B






posted by SDozono at 17:17| “Œ‹ž ☀| Comment(0) | TrackBack(0) | CakePHP General | ‚}‚̃uƒƒO‚Ì“ÇŽÒ‚É‚È‚é | XVî•ñ‚ðƒ`ƒFƒbƒN‚·‚é
‚�}‚Ì‹LŽ–‚ւ̃Rƒƒ“ƒg
ƒRƒƒ“ƒg‚ð‘‚­
‚�N–¼‘O: [•K{“ü—Í]

ƒ[ƒ‹ƒAƒhƒŒƒX:

ƒz[ƒ€ƒy[ƒWƒAƒhƒŒƒX:

ƒRƒƒ“ƒg: [•K{“ü—Í]

”FØƒR[ƒh: [•K{“ü—Í]


¦‰æ‘œ‚Ì’†‚̕��Žš‚𔼊p‚Å“ü—Í‚µ‚Ä‚­‚¾‚³‚��B

‚�}‚Ì‹LŽ–‚ւ̃gƒ‰ƒbƒNƒoƒbƒN
Žèiƒp[jTo make a comment: Please type your name and comment. at the validation field box, type 'cakephp'. And there two glay buttons. "Preview"/"Submit". Thank you!