Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to implement SQL logs in a legacy project #517

Open
garbinmarcelo opened this issue Jan 11, 2023 · 4 comments
Open

How to implement SQL logs in a legacy project #517

garbinmarcelo opened this issue Jan 11, 2023 · 4 comments

Comments

@garbinmarcelo
Copy link

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

@garbinmarcelo
Copy link
Author

Any help with this issue? 😬

@mx03
Copy link

mx03 commented Aug 20, 2023

The biggest question is which database php backend is used, mysqli, pdo, mysql?

@garbinmarcelo
Copy link
Author

The biggest question is which database php backend is used, mysqli, pdo, mysql?

We use MariaDB

@parallels999
Copy link
Contributor

parallels999 commented Sep 18, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants