dpik71879
dpik71879
2012-09-14 14:19

Symfony 2中我的数据库中最后一次插入/更新/删除的时间

已采纳

I need a function that returns last time of insert / update / delete in my database. I use Symfony 2 and Doctrine 2.

I have tried this raw query, but UPDATE_TIME is always NULL:

$connection = $this->getDoctrine()->getConnection();
$database = $connection->getDatabase();

$result = $connection->fetchAll('
    SELECT MAX(UPDATE_TIME)
    FROM information_schema.tables
    WHERE TABLE_SCHEMA = "' . $database . '"
');

How can I get this last time in Symfony or Doctrine? Thanks.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • doubo7131 doubo7131 9年前

    I bet you're using InnoDB, and InnoDB doesn't support UPDATE_TIME.

    Your best bet is to create an event and populate/update a table each time you're inserting/updating a row.

    点赞 评论 复制链接分享