dpp3047 2012-09-11 03:17
浏览 30
已采纳

一般会使codeigniter对象或php无效吗?

I am using codeigniter and PHP to build a web app and there are lot of objects that I have to define/use inside models due to large number of queries that I have to execute. Sometime I have to use same object multiple times inside a loop, for example:

  $dbData = $this->mydb->query($dbQuery);
  if($dbData->num_rows() >0 ){ //check if rows were returned
     $dbResult = $dbData->result();
     foreach( $dbResult as $index => $row){
        $dbArray[$row->JOB_NAME_STG] = $row->REC_LOADED;
    }

In general programming practice you should nullify the objects once they are no longer required but I haven't been able to find any detail on the best way to ensure that all the objects are nullified avoiding memory leaks for codeigniter or php in general.

Is assigning NULL to an object at the end of the function sufficient?

$dbData = $this->mydb->query($dbQuery);
$dbData = NULL;

Or codeigniter has more efficient way of ensuring that there are no memory leaks.

Should object be nullified inside a loop before using to ensure there is no memory leak?

Any pointers in the direction will be appreciated. Thanks!!!

  • 写回答

2条回答 默认 最新

  • drh37116 2012-09-11 03:19
    关注

    Assigning null makes no sense in:

    1. php >= 5.3
    2. applications, that don't work for hours

    Do you match both items above?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突