• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
db->insert error

#1
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
Reply

#2
(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?
Reply

#3
(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,
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.