Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8118983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:39:55+00:00 2026-06-06T04:39:55+00:00

I am trying to get the new PDO driver running in Code Igniter 2.1.1

  • 0

I am trying to get the new PDO driver running in Code Igniter 2.1.1 in (to start with) the local (Mac OS 10.7) copy of my app.
I initially coded it using Active Record for all db operations, and I am now thinking I want to use PDO prepared statements in my model files, going forward.

I modified ‘application/config/database.php’ like so:
(note a couple minor embedded questions)

[snip]

$active_group = 'local_dev';

$active_record = TRUE;//<---BTW, will this need to stay TRUE to make CI sessions work?  For better security, don't we want db-based CI sessions to use PDO too?
//http://codeigniter.com/user_guide/database/configuration.html:
    //Note: that some CodeIgniter classes such as Sessions require Active Records be enabled to access certain functionality.

//this is the config setting that I am guessing (?) is my main problem: 

$db['local_dev']['hostname'] = 'localhost:/tmp/mysql.sock';

// 1.) if $db['local_dev']['dbdriver']='mysql', then here ^^^ 'localhost:/tmp/mysql.sock' works, 2.) but if $db['local_dev']['dbdriver']='pdo', then it fails with error msg. shown below.

$db['local_dev']['username'] = 'root';
$db['local_dev']['password'] = '';
$db['local_dev']['database'] = 'mydbname';
$db['local_dev']['dbdriver'] = 'pdo';
$db['local_dev']['dbprefix'] = '';
$db['local_dev']['pconnect'] = TRUE;
$db['local_dev']['db_debug'] = TRUE;//TRUE
$db['local_dev']['cache_on'] = FALSE;
$db['local_dev']['cachedir'] = '';
$db['local_dev']['char_set'] = 'utf8';
$db['local_dev']['dbcollat'] = 'utf8_general_ci';
$db['local_dev']['swap_pre'] = '';
$db['local_dev']['autoinit'] = TRUE;
$db['local_dev']['stricton'] = FALSE;
[snip]

With the above config., as soon as I load a controller, I get this error message:

Fatal error: Uncaught exception 'PDOException' with message 'could not find driver' in 
/Library/WebServer/Documents/system/database/drivers/pdo/pdo_driver.php:114 Stack trace: #0 
/Library/WebServer/Documents/system/database/drivers/pdo/pdo_driver.php(114): PDO->__construct('localhost:/tmp/...', 'root', '', Array) #1 /Library/WebServer/Documents/system/database/DB_driver.php(115): CI_DB_pdo_driver->db_pconnect() #2 
/Library/WebServer/Documents/system/database/DB.php(148): CI_DB_driver->initialize() #3 
/Library/WebServer/Documents/system/core/Loader.php(346): DB('', NULL) #4 
/Library/WebServer/Documents/system/core/Loader.php(1171): CI_Loader->database() #5 
/Library/WebServer/Documents/system/core/Loader.php(152): CI_Loader->_ci_autoloader() #6 
/Library/WebServer/Documents/system/core/Con in 
/Library/WebServer/Documents/system/database/drivers/pdo/pdo_driver.php on line 114

I tried swapping out the ‘pdo_driver.php’ file from the one on github, as per this:
http://codeigniter.com/forums/viewthread/206124/
…but that just generates other errors, not to mention is disturbing to a newbie who does not want to touch the system files if at all possible.

This thread also seems to imply the need to be hacking the ‘pdo_driver.php’ system file:
CodeIgniter PDO database driver not working
It seems odd to me, though, that (someone thought that) a hack to a system file is needed to make PDO work in CI v.2.1.1, huh?

Thanks for any suggestions I can try.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T04:39:58+00:00Added an answer on June 6, 2026 at 4:39 am

    thanks to the noob thread http://codeigniter.com/forums/viewthread/180277/ (InsiteFX’s answer)..

    I figured out the below seems to work (need to test more to be 100%… but at least the error messages are gone:

    $db['local_dev']['hostname'] = 'mysql:host=127.0.0.1'; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I´m new to PhoneGap/CoffeeScript trying to get a Hello World App running in iOS
New demo code: I am trying to get the captcha image from a AOL,
I'm trying to get into PDO details. So I coded this: $cn = getConnection();
I'm trying to get a new DotNetNuke site up and running on our 64-bit
I'm trying to get a new SDL application running on Ubuntu 11.10 and am
New to PDO ... i am trying to get sum but getting error here
I'm trying to get a new Enterprise Application Project set up in Eclipse using
I am trying to get a new dynamically created row to add to a
I'm trying to get the new ASP.NET Web API beta (VS 2010 default Web
I'm trying to get (and store) new position of a dynamically added panels to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.