Zend_Db_Expr NOW () not working?

I am trying a simple insert:

$data = array
(
'whatever' => 'nevermind',
'etc' => 'more data',
'updated_on' => new Zend_Db_Expr('NOW()')
);

$this->getDbTable()->insert( $data );

Everything is inserted correctly, but updated_on is null. Am I doing something wrong? I understand that it may not be easy to determine the problem from what I said, but perhaps you could offer at least how can I debug this? thanks in advance

ps the database is mySQL and the column is DATETIME, and if I connect to mySQL and manually try to insert or update NOW (), this will work.

Update

Using Profiler, I get the following output:

INSERT INTO `db_table` (`column1`, `column2`, `column3`, `column4`, `column5`, `column6`, `column_datetime`, `column7`) VALUES (?, ?, ?, ?, ?, ?, NOW(), ?)

Array
(
    [1] => column1 data
    [2] => column2 data
    [3] => column3 data
    [4] => column4 data
    [5] => column5 data
    [6] => column6 data
    [7] => column7 data
)

As far as I know, everything is in order: \

Update2: Nevermind, I got it working. The problem was completely different.

+3
source share
1 answer

, , .

, profiler :

$db = $this->getDbTable();
$adapter = $db->getAdapter();
$adapter->getProfiler()->setEnabled(true);
$data = array
(
    'whatever' => 'nevermind',
    'etc' => 'more data',
    'updated_on' => new Zend_Db_Expr('NOW()')
);
$db->insert( $data );
print $adapter->getProfiler()->getLastQueryProfile()->getQuery();
print_r($adapter->getProfiler()->getLastQueryProfile()->getQueryParams());
$adapter->getProfiler()->setEnabled(false);
+7

Source: https://habr.com/ru/post/1790657/


All Articles