CodeIgniter Forums
PDO connection and values - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: PDO connection and values (/showthread.php?tid=63327)



PDO connection and values - silassiai - 10-20-2015

To connect with PDO this is not working:
(https://codeigniter.com/user_guide/database/connecting.html)
$db['pdo'] = array(
'dsn' => 'mysql:host=localhost;dbname=your_db_name',
// remaining configs
);

This works:
$db['pdo'] = array(
'dsn' => '',
'hostname' => 'mysql:host=localhost;dbname=your_db_name',
'username' => 'user_name',
'password' => 'password',
'database' => '',
'dbdriver' => 'pdo'
// remaining configs
);

Why is that?

If i run this query the num_rows is 1 but the result is empty:
$sql = "SELECT id, username, password FROM {pre}dashboard_users WHERE username = ? AND password = ? LIMIT 1";
$query = $this->db->query($sql, array($username, md5($password)));

if($query->num_rows() == 1)
{
return $query->result();
} else {
return false;
}

what am i doing wrong?