Hi temury416!
I do not know the exact amount of db interaction but you could add an event handler to the db object to log these interactions. In the following code the log file "db.log" is stored in the app/logs/ folder. You can change it if you want or you have to create the logs folder.
$di->set('db', function() use ($config) {
$connection = new \Phalcon\Db\Adapter\Pdo\Mysql(array(
'host' => $config->database->host,
'port' => $config->database->port,
'username' => $config->database->username,
'password' => $config->database->password,
'dbname' => $config->database->dbname,
'options' => [
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
PDO::ATTR_EMULATE_PREPARES => false,
PDO::ATTR_STRINGIFY_FETCHES => false,
]
));
$eventsManager = new Phalcon\Events\Manager();
$logger = new Phalcon\Logger\Adapter\File("../app/logs/db.log");
/**
* Listen all the database events
*/
$eventsManager->attach('db', function($event, $connection) use ($logger) {
if ($event->getType() == 'beforeQuery') {
$logger->log($connection->getSQLStatement(), \Phalcon\Logger::INFO);
}
});
$connection->setEventsManager($eventsManager);
return $connection;
});
Best regards