Zend \ Dbおよび/またはTableGatewayinsert()/ update()ステートメントを介してZF2(2.0.0beta4)の現在のビルドにNOW()のようなMySQL式を含める方法はありますか?
まだ回答されていませんが、メーリングリストの関連記事は次のとおりです。http://zend-framework-community.634137.n4.nabble.com/Zend-Db-Expr-and-Transactions-in-ZF2- Db-td4472944.html
ZF1は次のようなものを使用したようです。
$data = array(
'update_time' => new \Zend\Db\Expr("NOW()")
);
そして、Zend \ Db \ Sql \ Expressionを調べた後、私は次のことを試しました。
$data = array(
'update_time' => new \Zend\Db\Sql\Expression("NOW()"),
);
ただし、次のエラーが発生します。
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
ここで推奨されているように:http://zend-framework-community.634137.n4.nabble.com/ZF2-beta3-Zend-Db-Sql-Insert-new-Expression-now-td4536197.html現在設定しているのはPHPコードを使用した日付ですが、日付/時刻の信頼できる唯一の情報源としてMySQLサーバーを使用したいと思います。
$data = array(
'update_time' => date('Y-m-d H:i:s'),
);
ありがとう、私はどんな入力にも感謝します!