CodeIgniter Active Record: Load One Row at a Time

后端 未结 4 637
迷失自我
迷失自我 2020-12-19 15:33

The normal result() method described in the documentation appears to load all records immediately. My application needs to load about 30,000 rows, and one at a

4条回答
  •  佛祖请我去吃肉
    2020-12-19 16:13

    Here is something you can do.

    while ($row = $result->_fetch_object()) {
      $data = array(
        'id'         => $row->id
        'some_value' => $row->some_field_name
      );
      // send row data to whatever api
      $this->send_data_to_api($data);
    }
    

    This will get one row at the time. Check the CodeIgniter source code, and you will see that they will do this when you execute the result() method.

提交回复
热议问题