ÔÚzendframeworkÖÐʹÓÃDbÀàʱ£¬¿ò¼Ü»á×Ô¶¯¸øsqlÓï¾äÌí¼ÓÒýºÅÒÔ·ÀÖ¹Êý¾Ý¿â¹¥»÷ £¬Õâ¾Íµ¼ÖÂÁËÒ»¸öÎÊÌ⣬Óû§ÎÞ·¨Ê¹ÓÃzend dbÀàʹÓÃmysqlµÄÄÚÖú¯Êý£¨·½·¨£¬´æ´¢¹ý³ÌµÈ£©¡£ºÃÔÚzend¿ò¼ÜÌṩÁËÒ»¸öÀàZend_Db_Expr£¬´ËÀàµÄ¹¹Ô캯Êý»á¸æËß¿ò¼Ü²»Òª¶ÔËüËùת»¯µÄÀàÐͽøÐÐÌí¼ÓÒýºÅµÄ²Ù×÷¡£
public function setBatchDelete($orderIds) {
$flag = YCL_Order::FLAG_DELETED;
$updateTime = time();
$data = array(
'flag' => new Zend_Db_Expr("flag | $flag"),
'update_time' => $updateTime
);
$db = $this->getAdapter();
$where = $db->quoteInto('service_order_id IN (?)',$orderIds);
$this->update($data,$where);
}
ÉÏÃæµÄÀý×Ó ×ó±ßµÄflagÊÇÊý¾Ý¿âÖеÄflag¡£
$select=$db->select();
$select->from("testtable","*");
$select->where($db->quotInto("date>=?",new Zend_Db_Expr("UNIX_TIMESTAMP()"));
$db->fetchAll($select); ¿ò¼Ü²»»á¶ÔUNIX_TIMESTAMP()Ìí¼ÓÒýºÅ£¬´Ó¶øÈÃÓû§ÄÜÕý³£Ê¹Óô˺¯Êý¡£
You also can create an object of type Zend_Db_Expr explicitly, to prevent a string from being treated as a column name.