找出mysqli查询字符串

时间:2012-08-09 21:15:31

标签: php mysqli

简短的问题,但显然谷歌和php.net都不知道这一点,所以我很好奇是否有可能。

你能获得mysqli元素的查询字符串吗?我需要它来制作一个正确的错误函数

$mysqli = new mysqli(....);
$mysqli->query('INSERT INTO test(value) VALUES ('.rand(1,10000).');');
// here how do i find out the query of the $mysqli object WITHOUT having 
// to save it before (i.e. using the actual $mysqli object)

谢谢!

2 个答案:

答案 0 :(得分:2)

http://www.php.net/manual/en/class.mysqli-result.php判断 - 你不能。

$mysqli->query()是一个方法调用,它返回mysqli_result个对象,并查看上面的手册页,它不包含刚创建它的查询记录。

答案 1 :(得分:-2)

我不确定我理解你的问题,但是:

$sql = "INSERT INTO test(value) VALUES ('.rand(1,10000).');";
$mysqli->query($sql);

...然后,在你的scirpt之后,你可以参考$sql

if($sql = '...'){...}