Esiste un modo per includere espressioni MySQL come NOW() nella build corrente di ZF2 (2.0.0beta4) tramite Zend \ Db e/o istruzioni TableGateway insert()/update()?ZF2 Zend Db Insert/Update utilizzando l'espressione Mysql (Zend Db Sql Expression?)
Ecco un post correlati nella mailing list, anche se non ha ricevuto risposta: http://zend-framework-community.634137.n4.nabble.com/Zend-Db-Expr-and-Transactions-in-ZF2-Db-td4472944.html
Sembra che ZF1 utilizzato qualcosa come:
$data = array(
'update_time' => new \Zend\Db\Expr("NOW()")
);
E dopo aver guardato attraverso Zend \ Db \ Sql \ Expression ho provato:
$data = array(
'update_time' => new \Zend\Db\Sql\Expression("NOW()"),
);
Ma il seguente errore:
Catchable fatal error: Object of class Zend\Db\Sql\Expression could not be converted to string in /var/www/vendor/ZF2/library/Zend/Db/Adapter/Driver/Pdo/Statement.php on line 256
Come consigliato qui: http://zend-framework-community.634137.n4.nabble.com/ZF2-beta3-Zend-Db-Sql-Insert-new-Expression-now-td4536197.html Attualmente sto impostando la data con il codice PHP, ma preferisco usare il server MySQL come unica fonte di verità per data/ora.
$data = array(
'update_time' => date('Y-m-d H:i:s'),
);
Grazie, apprezzo qualsiasi ingresso!
Grazie per la risposta e il collegamento, io aggiornare all'ultima fonte e vedere se persiste. –
zend framework 2.0 beta 6 e ancora nessuna soluzione a questo problema!?!?! – ufk
problema risolto in zend framework 2.0 beta 7 – ufk