CodeIgniter Forums
db->insert error - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: db->insert error (/showthread.php?tid=67134)



db->insert error - DEVULDER - 01-19-2017

PHP Code:
        for($i 0$i 1000000;$i++){
            
$uid uniqid('rsv'true);

            
$this->db->set('uid',$uid);
            
$this->db->set('data','toto' $i);
            
$this->db->reset_query();
            if ( 
$this->db->insert('ddr') == false ){

                break;
            }
            
$this->db->reset_query();
        } 

Error message Fatal error: Allowed memory size of 134217728 bytes exhausted  in /system/database/DB_driver.php on line 703


RE: db->insert error - enlivenapp - 01-19-2017

(01-19-2017, 04:03 AM)DEVULDER Wrote:
PHP Code:
        for($i 0$i 1000000;$i++){
            
$uid uniqid('rsv'true);

            
$this->db->set('uid',$uid);
            
$this->db->set('data','toto' $i);
            
$this->db->reset_query();
            if ( 
$this->db->insert('ddr') == false ){

                break;
            }
            
$this->db->reset_query();
        } 

Error message Fatal error: Allowed memory size of 134217728 bytes exhausted  in /system/database/DB_driver.php on line 703

Um, 

well, first, you're resetting your query before you try to insert...

second... 1 million inserts is too much for your server's memory to handle at once with a for loop.

Did you have a question about it though?


RE: db->insert error - DEVULDER - 02-02-2017

(01-19-2017, 10:20 AM)enlivenapp Wrote:
(01-19-2017, 04:03 AM)DEVULDER Wrote:
PHP Code:
        for($i 0$i 1000000;$i++){
            
$uid uniqid('rsv'true);

            
$this->db->set('uid',$uid);
            
$this->db->set('data','toto' $i);
            
$this->db->reset_query();
            if ( 
$this->db->insert('ddr') == false ){

                break;
            }
            
$this->db->reset_query();
        } 

Error message Fatal error: Allowed memory size of 134217728 bytes exhausted  in /system/database/DB_driver.php on line 703

Um, 

well, first, you're resetting your query before you try to insert...

second... 1 million inserts is too much for your server's memory to handle at once with a for loop.

Did you have a question about it though?
 

The problem comes from the DB_Driver, to be precise the problem comes from a log array that is not reset. In the DB_Driver class the offending table is 'query_time' in the 'query' method.

Regards,