• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PDO in Codeigniter

#13
[eluser]Ickes[/eluser]
[quote author="Chad Fulton" date="1246923557"]
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;
[/quote]

Stupid me! There was an issue with my db connection. Thanks everyone for the help on this. Even though it was very painful, and probably painful for all involved, I learned a lot.

By using PDO like this, it does remove it from CodeIgniter's syntax. While the idea with CI is to reduce code by using Active Record, I think I will keep my db stuff in PDO. If someone is against this approach, I would love to hear why. I am definitely open minded for change.

Thanks again everyone!


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

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.