Is there a way to see the previous query entered in a MySQL server through PHP? I do not want the results of the query, I want the actual plaintext query entered.
Asked
Active
Viewed 98 times
-1
-
while you are entering data array into database, you will have already that information. And if you want new inserted ID then it will be based on which mysql connection you are using. But, in general case `$query->lastID();` – RNK Jun 23 '14 at 16:33
-
Make an attempt of your own first. :) – gsamaras Jun 23 '14 at 16:54
1 Answers
0
No. By default PHP disconnects and closes any mysql connections when the script ends, so there will be nothing left to view when the NEXT connection comes in. And since you have to send the query over each time anyways, by definition you should have that query available to you already. If you need the query text kept, then you should put it into a variable first
e.g. instead of
$result = mysql_query('SELECT ...');
you should be doing
$sql = 'SELECT ...';
$result = mysql_query($sql);

Marc B
- 356,200
- 43
- 426
- 500