在执行 INSERT 查询时,MySQL/PHP 是否返回任何内容?这是我在类里面的功能。
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;
}
函数是这样调用的
$rs = $dbh->mysqlQuery($query);
但是执行 INSERT
查询 $rs
不返回任何内容。我的功能需要帮助还是这是默认行为?任何提示也会有所帮助。
最佳答案
INSERT 只返回 true 或 false。要实际返回一些有用的东西,您将需要一个 SELECT 或类似的查询。没有可使用 INSERT 获取的结果。
关于PHP MySQL INSERT 执行一次查询返回值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1488237/