My question relates to identifying which table and schema a mysql command is executed on. I’m running this from a PDO wrapper in PHP
For example:
USE db1;
SELECT * FROM `table`;
I can get the name of the table from using DESCRIBE SELECT * FROM table and assume that the name of the schema is db1.
Now, when i want to do something like this
USE db1;
SELECT * FROM `db2`.`table`
I can get the name of the table using the describe command again. However i can not find a method in MySQL that gives me the schema on which the command was executed.
Is there a way to extract a database and table name from a MySQL command using regex. Assuming there is no join and the command is only a SELECT
Using the query the query analyzer produces should give you what you want I think. To be clear this is table test in database test.
Dont forget to do the show warnings