php-debugbar
php-debugbar copied to clipboard
How to implement SQL logs in a legacy project
Hello, would you know if I could do this to get the SQL queries in a legacy project? or even in pure mysql queries?
Currently Kohana v2 is used and in some controllers it is done: Database::instance()->query($query);
to get insert, update, select and delete. The project does not use queries via Model.
SQL call examples:
Database::instance()->query("SELECT * FROM table WHERE id = {$this->id}")[0];
or
$this->db = new Database();
$this->db->select('*')->from('table')->where('id', $this->id)>get()->current();
Could someone guide me how can I implement SQL logs? It would be very important to me.
Thanks
Any help with this issue? :grimacing:
The biggest question is which database php backend is used, mysqli, pdo, mysql?
The biggest question is which database php backend is used, mysqli, pdo, mysql?
We use MariaDB
Here is the MySQL Kohana/Database/MySQL.php
// Set the last query
$this->last_query = $sql;
With that, make a query collector, like this: DebugBar/DataCollector/PDO/PDOCollector.php Another examples: DebugBar/Bridge/DoctrineCollector.php DataCollector/QueryCollector.php koseven-debug-toolbar