Welcome Guest, Not a member yet? Register   Sign In
PDO Help Needed
#1
Exclamation 

I am unable to get PDO run in Codeigniter 3.0.1.
I have set up the PDO as it is in CI Docs, but unable to get it run.

Getting error.. $db undefined

Kindly help.
Reply
#2

(10-05-2015, 06:05 AM)dharmender Wrote: I am unable to get PDO run in Codeigniter 3.0.1.
I have set up the PDO as it is in CI Docs, but unable to get it run.

Getting error.. $db undefined

Kindly help.

For PDO you should specify the DSN correctly. For example with MySQL:

PHP Code:
$db['default'] = array(

        'dsn'   => 'mysql:host=localhost;dbname=your_db_name',

 
       // remaining configs
); 
Reply
#3

I am getting the following error:
Fatal error: Call to undefined method CI_Loader::prepare()

Following are my configs:

$db['default']['dsn'] = 'mysql:host=localhost;dbname=db_name;charset=utf8;';

$db['default']['username'] = 'db_user';
$db['default']['password'] = 'db_pass';

$db['default']['dbdriver'] = 'pdo';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = FALSE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = TRUE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;
Reply
#4

(10-06-2015, 12:16 AM)dharmender Wrote: I am getting the following error:
Fatal error: Call to undefined method CI_Loader::prepare()

What is the code you are using when this error occurs? It looks like you're trying to use the PDO::prepare() method, which isn't going to work with CI's DB class.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB