Archive for 2007年11月

Zend_Db quoteInto

11月 22nd, 2007

updateでquoteIntoを使ったwhere条件が複数ある場合、記述方法をよく忘れるのでメモ。

// 複数の条件を AND で組み合わせます
$where   = array(
    $db->quoteInto('first_name = ?', $firstName),
    $db->quoteInto('noble_title = ?', $nobleTitle)
);
$count   = $db->update('round_table', $set, $where);
 
// 複数の条件を OR で組み合わせます
$firstNameOne = $db->quote($firstNameOne);
$firstNameTwo = $db->quote($firstNameTwo);
$where        = "first_name = $firstNameOne OR first_name = $firstNameTwo";
$count        = $db->update('round_table', $set, $where);