I am interested in getting the last time a table was updated (which is not necessarily the newest entry - entries might be deleted as well).
In SQL, the solution is easy:
SELECT UPDATE_TIME FROM information_schema.tables
WHERE TABLE_SCHEMA = 'myDb' AND TABLE_NAME = 'myTable';
However, the only way I manage to do so is to create a new connection.
Assume that my connection is called mysqlConn
, my new conenction will look like:
'mysqlConnScheme' => [
'driver' => *** same as mysqlConn ***,
'host' => * - " - *,
'port' => * - " - *,
'username' => * - " - *,
'password' => * - " - *,
'database' => 'information_schema',
],
Then I can retrieve it by:
$updateTime = DB::connection('mysqlConnScheme')
->setDatabaseName('information_schema')
->table('tables')
->select('UPDATE_TIME')
->where('TABLE_SCHEMA', '=', 'myDb')
->where('TABLE_NAME', '=', 'myTable')
->first();
I wonder if there is any way to do so without creating another connection.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire