PDO Codeigniter Integration

I researched a lot on the Internet, but I did not find anything that could help me use PDO in the encoder. I saw in the LI CI 2.1.0 change (I think) that the pdo driver was added to the framework. Now I am done with the database.php configuration file, which looks like this:

$db['default']['hostname'] = 'mysql:host=myhostname;port=myport'; 
$db['default']['username'] = 'myusername';
$db['default']['password'] = 'mypassword'; 
$db['default']['database'] = 'mydb'; 
$db['default']['dbdriver'] = 'pdo';

So, now (after a lot of wasted time to get the snippet above to work -.-), I do not get a connection error, but HOW DO I REQUEST NOW? I can't figure out what syntax will work and how to build queries. Does anyone have any clues?

PS: if you talk about why I need pdo in qi, the answer is my boss wants me to create a structured environment with:

  • CI 2.x + (done)
  • Smarty 3 (done)
  • PhpUnit (not yet)
  • PDO (not yet)

, - phpunit, . Ty

+5
2

PDO , CodeIgniter. , .

, , ( ).

:

// Standard query
$results = $this->db->query('SELECT name, title, email FROM my_table');

// Active record
$this->db->select('name, title, email');
$results = $this->db->get('my_table');

PHPUnit, https://github.com/cmillr/CI-PHPUnit ( ) CodeIgniter. PHPUnit CodeIgniter.

+7

:

'dsn'   => 'mysql:host=localhost;dbname=codeigniter',
//'hostname' => 'localhost',
'username' => 'codeigniter',
'password' => 'codeigniter',
'database' => 'codeigniter',

, dsn, .

$this->db->, - PDO PDO

, , - , :

http://codebyjeff.com/blog/2013/03/codeigniter-with-pdo

+8

All Articles