Version: v2.4.0
log
Return the executed query log.
log()
Return Value
[array] An array containing the recorded SQL queries.
If
logging => true is enabled during initialization, all recorded queries are returned. Otherwise, only the most recent query is returned.$database = new Medoo([
"type" => "mysql",
"host" => "localhost",
"database" => "name",
"username" => "your_username",
"password" => "your_password",
// Enable query logging.
"logging" => true,
]);
$database->select("account", [
"user_name",
"email"
], [
"user_id[<]" => 20
]);
$database->insert("account", [
"user_name" => "foo",
"email" => "foo@bar.com"
]);
var_dump($database->log());
// Output:
// array(2) {
// [0]=> string(62) "SELECT "user_name","email" FROM "account" WHERE "user_id" < 20"
// [1]=> string(74) "INSERT INTO "account" ("user_name", "email") VALUES (\'foo\', \'foo@bar.com\')"
// }
// With `"logging" => false` (the default), only the latest query is retained.
// array(1) {
// [0]=> string(74) "INSERT INTO "account" ("user_name", "email") VALUES (\'foo\', \'foo@bar.com\')"
// }