Reputation: 33
Is there anyway I can see a query once it has been run and all variables have been instantiated?
e.g. I want to see the end result (String) of
$query = $this->db->query("SELECT email, password FROM users
WHERE email = '$email' AND password = 'PASSWORD($password)'");
I would like to see the query string after PASSWORD($password) has been done.
Upvotes: 0
Views: 139
Reputation: 27835
The query string doesn't change inside MySql, but you can do something like this to see what the password will look like:
$query = $this->db->query("SELECT PASSWORD('".mysql_real_escape_string($password)."')");
Upvotes: 3
Reputation: 33
I needed to change 'PASSWORD($password)'
to:
PASSWORD('$password')
This fixed my issue.
Upvotes: 0
Reputation: 11385
You can store the string as a variable before hand.
eg)
$query = "SELECT email, password FROM users
WHERE email = '$email' AND password = 'PASSWORD($password)'";
and then output the query with var_dump($query)
.
$this->db->query($query);
It is better practice though to use prepared statements and feed in escaped variables.
Upvotes: 0