Zend_Db更新问题

时间:2013-11-30 12:49:52

标签: php zend-framework sql-update zend-db

嘿,我有以下SQL:

UPDATE table_name`
SET opt_out = '1',
 opt_out_date = NOW(),
 admin_uid = '471',
 last_updated = now()
WHERE
    mem_uid = '7445093'
    AND opt_out = '0'
    AND verified = '0'
    AND reverted_credit_flag = '0'
ORDER BY
    id DESC
LIMIT 1`

我希望在PHP中反映...

 Zend_Db_Table::getDefaultAdapter();

$tableName = new Zend_Db_Table('table_name');

$data = array(
    'opt_out' => 1,
    'opt_out_date' => new Zend_Db_Expr('NOW()'),
    'admin_uid' => $admin_id,
    'last_updated' => new Zend_Db_Expr('NOW()')
);

$where = array(
    'mem_uid' => $mem_id,
    'opt_out' => '0',
    'verified' => '0',
    'reverted_credit_flag' => '0'
);

return $tableName ->update($data, $where);

它不起作用,没有错误,只是没有...... 来自$ db的转储就是这个......

class Zend_Db_Adapter_Pdo_Mysql#149(12){   protected $ _pdoType =>   string(5)“mysql”   protected $ _numericDataTypes =>   array(16){     [0] =>     INT(0)     [1] =>等...

1 个答案:

答案 0 :(得分:2)

尝试使用此数组表示法:

$where = array(
    'mem_uid = ?' => $mem_id,
    'opt_out = ?' => '0',
    'verified = ?' => '0',
    'reverted_credit_flag = ?' => '0'
);

Reference (Example #24)