mysqli_result :: free和mysqli_stmt :: free_result是否相同? [英] Are mysqli_result::free and mysqli_stmt::free_result the same?
问题描述
我写了这段代码:
$stmt = $link->prepare($statement_string);
// [...]
$result_m = $stmt->result_metadata();
if ($result_m) {
$stmt->store_result();
// [...]
$stmt->free_result();
$result_m->free();
}
该代码正确吗?
我阅读了文档 mysqli-stmt.result-metadata 和 mysqli-result.free文档.我也阅读了这篇文章: ... free-mysql-result -存储后,但我没有找到答案.
I read the doc mysqli-stmt.result-metadata and mysqli-result.free doc. I also read this post : ...free-mysql-result-after-storing-it but I didn't find my answer.
我想知道的是:$stmt->free_result();
会只是释放$stmt->store_result();
完成的某些内存分配还是明确释放$stmt->result_metadata();
构建的mysqli_result
对象的内存?
What I want to know is : will the $stmt->free_result();
just liberate some memory allocation done by $stmt->store_result();
or clearly free the memory of the mysqli_result
object built by $stmt->result_metadata();
?
推荐答案
根据这些页面:
元数据和实际语句数据(行)是不同的对象,因此必须分别清除它们.
meta data and actual statement data (rows) are different objects so you must clear them both separately.
与您在代码中所做的完全一样.
exactly as you did in your code.
这篇关于mysqli_result :: free和mysqli_stmt :: free_result是否相同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!