[eluser]Chad Fulton[/eluser]
I think that there is some confusion in this thread about the way PDO and CI are being integrated. In kgill's DB.php hack, he essentially just makes it so that $this->db
is a PDO object.
So, in his approach, $this->db is identical to the following:
Code:
$pdo = new PDO( ... )
In other words, $this->db is
no longer connected to CodeIgniter in any way. Maybe this is where your confusion is coming from. Since you are making $this->db a PDO object, you can use it exactly as you normally would (I think you mentioned that you have some familiarity with PDO?).
Edit:
Whoops, posted this too late, and you'd already gotten to the $stmt->fetch(); part.
As far as I can see, there is some bug in your code somewhere, unfortunately since I can't see it and your database I don't know what it is.
Try this, for debugging:
Code:
//dummy variable
$pass_thru = 5;
$stmt = $this->db->prepare("SELECT * FROM tbl_blog WHERE blog_id <= :test");
$stmt->bindParam(':test', $pass_thru, PDO::PARAM_INT);
// Notice that execute() returns TRUE on success, FALSE on failure
if($stmt->execute()) {
echo count($stmt->fetchAll(PDO::FETCH_ASSOC));
}
else {
print_r($stmt->errorInfo());
}
die;