나는 OR 절을 사용하여 Zend db 업데이트를하고 싶습니다. 에 해당하는 문이 될 것입니다 무엇 :Zend DB 업데이트의 OR 절?
UPDATE mail
SET message_read = 1
WHERE id = 5
OR id = 10
나는 OR 절을 사용하여 Zend db 업데이트를하고 싶습니다. 에 해당하는 문이 될 것입니다 무엇 :Zend DB 업데이트의 OR 절?
UPDATE mail
SET message_read = 1
WHERE id = 5
OR id = 10
, 여러 WHERE
조건이 자동으로 AND
(기능 _whereExpr 라인 젠드/DB/어댑터/Abstract.php의 698)를 사용하여 결합됩니다 Zend_Db_Adapter::update()
를 호출.
Zend_Db_Expr
을 WHERE
조건으로 사용하면이 문제를 해결할 수 있습니다.이 상태는 그대로 유지됩니다. 예를 들어
:
$where[] = new Zend_Db_Expr(
$table->getAdapter()->quoteInto('id = ?', 5) . ' OR ' .
$table->getAdapter()->quoteInto('id = ?', 10)
);
// resulting expression:
// WHERE (id = 5 OR id = 10)
$table->update($data, $where);
추가 WHERE
조건을 가지고있는 경우는, 그들이는 AND
으로 OR
조건과 결합 될 것입니다.
예 :
$where[] = new Zend_Db_Expr(
$table->getAdapter()->quoteInto('id = ?', 5) . ' OR ' .
$table->getAdapter()->quoteInto('id = ?', 10)
);
$where[] = $table->getAdapter()->quoteInto('type = ?', 'sometype');
// resulting expression:
// WHERE (id = 5 OR id = 10) AND (type = 'sometype')
위대한, 감사합니다! – joeschmidt45
-> 여기서()가 추가됩니다 어디 쿼리 절과 'AND'를 넣어 것입니다. 이를 수행하는 방법이 있습니다.
$select = $this->select();
$select->where('id = 5');
$select->orWhere('id = 10');
$this->fetchAll($select);
의
가능한 중복 (http://stackoverflow.com/questions/6321504/how-to-use-multiple-conditions-in-an [Zend_Db와 QuoteInto와 UPDATE 문에서 여러 조건을 사용하는 방법] -update-statement-with-zend-db-and-quoteinto) – cmbuckley
@cbuckley 이것은 OP가 원하지 않는 'AND'를 사용하여 WHERE를 결합합니다. – drew010