Welcome Guest, Not a member yet? Register   Sign In
[Solved] How to use PDO in codeigniter 3
#1

(This post was last modified: 06-15-2015, 08:56 AM by wolfgang1983.)

I am trying to understand how PDO working in database.php from here http://www.codeigniter.com/user_guide/da...hlight=pdo but not working


PHP Code:
$active_group 'default';
$query_builder TRUE;

$db['default'] = array(
    
'dsn'    => 'pgsql:host=localhost;port=3306;dbname=myproject',
    
'hostname' => 'localhost',
    
'username' => 'root',
    
'password' => '*********',
    
'database' => 'myproject',
    
'dbdriver' => 'pdo',
    
'dbprefix' => '',
    
'pconnect' => FALSE,
    
'db_debug' => TRUE,
    
'cache_on' => FALSE,
    
'cachedir' => '' ,
    
'char_set' => 'utf8',
    
'dbcollat' => 'utf8_general_ci',
    
'swap_pre' => '',
    
'encrypt' => FALSE,
    
'compress' => FALSE,
    
'stricton' => FALSE,
    
'failover' => array(),
    
'save_queries' => TRUE
); 


Question How to use correct?
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply
#2

(06-15-2015, 03:49 AM)riwakawd Wrote: I am trying to understand how PDO working in database.php from here http://www.codeigniter.com/user_guide/da...hlight=pdo but not working



PHP Code:
$active_group 'default';
$query_builder TRUE;

$db['default'] = array(
    
'dsn'    => 'pgsql:host=localhost;port=3306;dbname=myproject',
    
'hostname' => 'localhost',
    
'username' => 'root',
    
'password' => '*********',
    
'database' => 'myproject',
    
'dbdriver' => 'pdo',
    
'dbprefix' => '',
    
'pconnect' => FALSE,
    
'db_debug' => TRUE,
    
'cache_on' => FALSE,
    
'cachedir' => '' ,
    
'char_set' => 'utf8',
    
'dbcollat' => 'utf8_general_ci',
    
'swap_pre' => '',
    
'encrypt' => FALSE,
    
'compress' => FALSE,
    
'stricton' => FALSE,
    
'failover' => array(),
    
'save_queries' => TRUE
); 


Question How to use correct?


Try this...


PHP Code:
$active_group 'default';
$query_builder TRUE;

$db['default'] = array(
 
   'dsn'  => 'mysql:host=localhost; dbname=myproject; charset=utf8;',
 
   'hostname' => 'localhost',
 
   'username' => 'root',
 
   'password' => '*********',
 
   'database' => '',
 
   'dbdriver' => 'pdo',
 
   'dbprefix' => '',
 
   'pconnect' => FALSE,
 
   'db_debug' => TRUE,
 
   'cache_on' => FALSE,
 
   'cachedir' => '' ,
 
   'char_set' => 'utf8',
 
   'dbcollat' => 'utf8_general_ci',
 
   'swap_pre' => '',
 
   'encrypt' => FALSE,
 
   'compress' => FALSE,
 
   'stricton' => FALSE,
 
   'failover' => array(),
 
   'save_queries' => TRUE
); 
Romanian CodeIgniter Team :: Translations :: Comunity :: Developers
http://www.codeigniter.com.ro
Reply
#3

(06-15-2015, 07:07 AM)Dracula Wrote:
(06-15-2015, 03:49 AM)riwakawd Wrote: I am trying to understand how PDO working in database.php from here http://www.codeigniter.com/user_guide/da...hlight=pdo but not working




PHP Code:
$active_group 'default';
$query_builder TRUE;

$db['default'] = array(
    
'dsn'    => 'pgsql:host=localhost;port=3306;dbname=myproject',
    
'hostname' => 'localhost',
    
'username' => 'root',
    
'password' => '*********',
    
'database' => 'myproject',
    
'dbdriver' => 'pdo',
    
'dbprefix' => '',
    
'pconnect' => FALSE,
    
'db_debug' => TRUE,
    
'cache_on' => FALSE,
    
'cachedir' => '' ,
    
'char_set' => 'utf8',
    
'dbcollat' => 'utf8_general_ci',
    
'swap_pre' => '',
    
'encrypt' => FALSE,
    
'compress' => FALSE,
    
'stricton' => FALSE,
    
'failover' => array(),
    
'save_queries' => TRUE
); 


Question How to use correct?


Try this...



PHP Code:
$active_group 'default';
$query_builder TRUE;

$db['default'] = array(
 
   'dsn'  => 'mysql:host=localhost; dbname=myproject; charset=utf8;',
 
   'hostname' => 'localhost',
 
   'username' => 'root',
 
   'password' => '*********',
 
   'database' => '',
 
   'dbdriver' => 'pdo',
 
   'dbprefix' => '',
 
   'pconnect' => FALSE,
 
   'db_debug' => TRUE,
 
   'cache_on' => FALSE,
 
   'cachedir' => '' ,
 
   'char_set' => 'utf8',
 
   'dbcollat' => 'utf8_general_ci',
 
   'swap_pre' => '',
 
   'encrypt' => FALSE,
 
   'compress' => FALSE,
 
   'stricton' => FALSE,
 
   'failover' => array(),
 
   'save_queries' => TRUE
); 

Working am I able to use mysqli in the dsn area?
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply
#4

(06-15-2015, 07:44 AM)riwakawd Wrote: Working am I able to use mysqli in the dsn area?

The PDO MySQL driver is not the same thing as the PHP MySQL driver, so there is no need to use mysqli (nor does it exist) with PDO.
Reply
#5

(06-15-2015, 08:31 AM)mwhitney Wrote:
(06-15-2015, 07:44 AM)riwakawd Wrote: Working am I able to use mysqli in the dsn area?

The PDO MySQL driver is not the same thing as the PHP MySQL driver, so there is no need to use mysqli (nor does it exist) with PDO.

Thank you for letting me know.
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB