Zend_Db Update issues

51 views Asked by At

Hey I have the below 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`

Which I want reflect in 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);

It doesn't work and no error, just nothing... The dump from $db is this...

class Zend_Db_Adapter_Pdo_Mysql#149 (12) { protected $_pdoType => string(5) "mysql" protected $_numericDataTypes => array(16) { [0] => int(0) [1] => etc...

1

There are 1 answers

1
Phliplip On BEST ANSWER

Try this array notation:

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

Reference (Example #24)