The solution may use query logging
http://book.cakephp.org/3.0/en/orm/database-basics.html#query-logging
you can turn on query logging only when you save your model and then turn it off
For example, I have a comment model
In my bootstrap.php I did
Log::config('current', [ 'className' => 'File', 'path' => LOGS.date('Y-m').DS,
and in my controller I did
$conn = \Cake\Datasource\ConnectionManager::get('default'); $comment = $this->Comments->get(5620); // 5620 is the id of one comments of mine $conn->logQueries(true); $comment = $this->Comments->get(5619); // 5619 is onother id of one comments of mine $comment->text = 'Test'; $this->Comments->save($comment); $conn->logQueries(false);
Thus, the file is created in the logs folder, and the file contains the following
2015-12-16 13:38:35 Debug: SELECT ... WHERE Comments.id = 5619 LIMIT 1 2015-12-16 13:38:35 Debug: BEGIN 2015-12-16 13:38:35 Debug: UPDATE comments SET text = 'Test' WHERE id = 5619 2015-12-16 13:38:35 Debug: COMMIT
note that the request used to get comment # 5620 was not logged
Also note that this works if you are not using debugkit
source share