在类方法中使用mysql_query并将其设置为局部变量时,在方法完成执行时或在脚本结束时释放内存?是否值得添加MysqL_free_result?以下是示例.
class example{
public function Query($query){
$result = MysqL_query($query);
while ($row = MysqL_fetch_assoc($result))
{
$this->rows[] =$row;
}
}
}
当方法完成时是否会释放内存,或者是否需要在方法结束时调用MysqL_free_result? 解决方法: 首先,不再维护MysqL_PHP函数,因此您可能希望使用更多OOP方法,例如mysqli或PDO函数.
自MysqL_free_result()
will free all memory associated with the result identifier result.
@H_404_21@
如果您正在获取大量结果,那么您可以(并且应该)使用此函数来释放您的MysqL以节省内存.
至于你的其余问题:
Will memory be freed when the method finishes or is it necessary to call MysqL_free_result at the end of the method?
@H_404_21@
不,如果您没有使用MysqL_free_result,则不会在方法结束时释放内存,而是在脚本执行结束时释放内存.
我希望它有所帮助.干杯. (编辑:北几岛)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|