RE: mysqli sql question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Peet,

Could you do something like this instead? This is using named placeholders
and a separate line for your statement
but I was able to get it to echo the statement in this manner. 

$sql = "UPDATE table SET field1=:field1, field2=:field2 WHERE id=:id";
		$sth = $dbh->prepare($sql);
		$sth->execute(array(":field1"=>$field1,
					   ": field2"=>$ field2,
					   ": id"=>$id));

echo $sql; 

Hope that helps,
Jen

-----Original Message-----
From: Peet Grobler [mailto:peet@xxxxxxxxxxxx] 
Sent: Wednesday, August 31, 2011 4:24 AM
To: php-general@xxxxxxxxxxxxx
Subject:  mysqli sql question

Is it possible to get the actual sql that is being used to query or
update the database?

E.g
$sth = $dbh->prepare ("update table set field=?, field2=? where id=?);
mysqli_bind_param ($sth, 'ssi', 'text1', 'text2', 10);
$sth->execute();

Something like $sth->sql? Or $dbh->sql?

I want to see "update table set field='text1', field2='text2' where id=10;


Thanks in advance,
Peet

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux