EllisLab text mark
Advanced Search
     
MySQL Driver support for client flags
Posted: 02 October 2007 11:29 AM   [ Ignore ]
Joined: 2007-05-20
6 posts

I have a project where MySQL server is different from webserver. So it’s difficult to use MySQL LOAD DATA LOCAL INFILE because client side does not support local_infile by default. Here mysql_connect() 5th and mysql_pconnect() 4th parameter $client_flags are necessary. CodeIgniter does not support this by default. So I have it enhanced.

Enhanced in mysql_driver.php

/**
     * Non-persistent database connection
     *
     * @access    private called by the base class
     * @return    resource
     */    
    
function db_connect()
    
{
        
return @mysql_connect($this->hostname$this->username$this->passwordTRUE$this->client_flags);
    
}
    
    
// --------------------------------------------------------------------

    /**
     * Persistent database connection
     *
     * @access    private called by the base class
     * @return    resource
     */    
    
function db_pconnect()
    
{
        
return @mysql_pconnect($this->hostname$this->username$this->password$this->client_flags);
    

Add additional default value to DB_driver.php

$defaults = array(
                                
'hostname'    => '',
                                
'username'    => '',
                                
'password'    => '',
                                
'database'    => '',
                                
'conn_id'    => FALSE,
                                
'dbdriver'    => 'mysql',
                                
'dbprefix'    => '',
                                
'port'        => '',
                                
'pconnect'    => FALSE,
                                
'db_debug'    => FALSE,
                                
'cachedir'    => '',
                                
'cache_on'    => FALSE,
                                
'client_flags' => NULL
                            
); 

And use setting in config/database.php

$db['default']['client_flags']    128;
// default NULL, 128 enables support for client side local_infile 

Oliver