PHP MySQL INSERT返回值,执行一次查询 [英] PHP MySQL INSERT return value with one query execution
本文介绍了PHP MySQL INSERT返回值,执行一次查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在执行INSERT查询时,MySQL/PHP是否返回任何内容?这是我在CLASS中具有的功能.
Is there anything returned from MySQL/PHP on a INSERT query being executed? Here is my function which I have in a CLASS.
function mysqlQuery($query) {
// Gets the results from the query
$results = mysql_query($query, $this->connection);
// Loops through the queried results as an multi-dimensional array
while($rows = mysql_fetch_array($results, MYSQL_ASSOC)) {
// Push results to single array
$rs[] = $rows;
}
// Return results as array
return $rs;
}
这就是我调用函数的方式
This is how I call the function
$rs = $dbh->mysqlQuery($query);
但是执行INSERT
查询时,$rs
不返回任何内容.我的功能是否需要帮助,或者这是默认行为吗?任何提示也将有所帮助.
But executing a INSERT
query the $rs
returns nothing. Does my function need help or is this the default behavior? Any tips would be helpful as well.
推荐答案
INSERT仅返回true或false.要真正返回有用的东西,您将需要SELECT或类似的查询.使用INSERT无法获取任何结果.
INSERT just returns true or false. to actually return something useful, you will need a SELECT or similar query. there is no result to fetch with INSERT.
这篇关于PHP MySQL INSERT返回值,执行一次查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文