Welcome Guest, Not a member yet? Register   Sign In
PDO in Codeigniter
#12

[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;


Messages In This Thread
PDO in Codeigniter - by El Forum - 07-02-2009, 01:05 PM
PDO in Codeigniter - by El Forum - 07-02-2009, 01:12 PM
PDO in Codeigniter - by El Forum - 07-02-2009, 01:44 PM
PDO in Codeigniter - by El Forum - 07-02-2009, 03:20 PM
PDO in Codeigniter - by El Forum - 07-03-2009, 04:09 PM
PDO in Codeigniter - by El Forum - 07-04-2009, 09:42 AM
PDO in Codeigniter - by El Forum - 07-04-2009, 10:20 AM
PDO in Codeigniter - by El Forum - 07-06-2009, 11:35 AM
PDO in Codeigniter - by El Forum - 07-06-2009, 12:02 PM
PDO in Codeigniter - by El Forum - 07-06-2009, 12:22 PM
PDO in Codeigniter - by El Forum - 07-06-2009, 12:31 PM
PDO in Codeigniter - by El Forum - 07-06-2009, 12:39 PM
PDO in Codeigniter - by El Forum - 07-06-2009, 12:53 PM



Theme © iAndrew 2016 - Forum software by © MyBB