Alex Pliutau
Alex Pliutau

Reputation: 21957

Time of last insert / update / delete in my database in 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.

Upvotes: 0

Views: 473

Answers (1)

Boris Guéry
Boris Guéry

Reputation: 47585

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.

Upvotes: 4

Related Questions