• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dump big rows using CI return error memory limit

#1
PHP Code:
<?php
defined
('BASEPATH') OR exit('No direct script access allowed');

class 
Migration extends CI_Controller {
    
    function 
test_ci()
    {
        
ini_set('memory_limit''2048M'); //i even tried -1 (my RAM is 8Gb)
        
$this->db->save_queries FALSE//just make sure save_queries disabled
        
$q $this->db->query("SELECT * FROM mytable"); 
        echo 
$q->num_rows(); 
    }
    
    function 
test_native(){
        
$serverName "****";
        
$connectionInfo = array( "Database"=>"****""UID"=>"****""PWD"=>"****" );
        
$conn sqlsrv_connect$serverName$connectionInfo);
        
$sql "SELECT * FROM mytable";
        
$stmt sqlsrv_query$conn$sql , [], ["Scrollable" => SQLSRV_CURSOR_KEYSET] );
        echo 
sqlsrv_num_rows$stmt );
    }
    


my database.php
PHP Code:
$active_group 'default';
$query_builder TRUE;

$db['default'] = array(
    
'dsn'    => '',
    
'hostname' => '***',
    
'username' => '***',
    
'password' => '***',
    
'database' => '***',
    
'dbdriver' => 'sqlsrv',
    
'dbprefix' => '',
    
'pconnect' => FALSE,
    
'db_debug' => (ENVIRONMENT !== 'production'),
    
'cache_on' => FALSE,
    
'cachedir' => '',
    
'char_set' => 'utf8',
    
'dbcollat' => 'utf8_general_ci',
    
'swap_pre' => '',
    
'encrypt' => FALSE,
    
'compress' => FALSE,
    
'stricton' => FALSE,
    
'failover' => array(),
    
'save_queries' => FALSE //disabled save_queries
); 

i want to dump all my rows (180k++ rows) for several purpose (like migration, etc). But i always get memory_limit error. 

So i create 2 method to compared my problem:

test_ci = fatal error memory_limit blabla
test_native = 180k++

NOTE:
Quote:1. in this demo i just try to count rows to simplify the demo code. But in the real case i have have complex script to parse the result.
2. i can hack this using Limit clause. But i just want to know how to do this using CI.


i tried to googling this for an hour but still not get any luck.
did i miss something?
Reply

#2
You would need to dump it out with phpMyAdmin.

You could then read and write out using CodeIgniter in chunks.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#3
While I agree with InsiteFX, my question is...did you check the PHP and CI error logs to see if you could get more information?
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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