user892134
user892134

Reputation: 3224

php pdo error handling difficulty

I am using firebug to see what is being returned with JSON and i get this array

 Array
(
    [0] => 00000
)

With Mysql i could simple do or die(mysql_error()).

Here is my query, I just changed it from mysql to prepared statement and now it isn't working.

        $construct =  $connectdb->prepare("SELECT rate.voted as rvote, child.*, sub.actionid as usersub, child.position as cnid FROM `table1` child 
        LEFT JOIN vote rate on rate.userid=:userid AND child.id=rate.blockid
        LEFT JOIN subscribe sub on sub.actionid=child.id AND sub.userid=:userid
        WHERE child.sid=:id AND child.position=:clickedposition
        ORDER BY cnid DESC,cid DESC $finalquerylimit");         

        $construct->execute(array(':userid'=>$userid,':id'=>$id,':clickedposition'=>$clickedposition));

This is what i used to get the error

print_r($construct->errorInfo());

I know the query isn't wrong because it works in MySql? any idea?

Upvotes: 0

Views: 229

Answers (2)

Akhilesh B Chandran
Akhilesh B Chandran

Reputation: 6608

The execute statement returns TRUE/FALSE value upon executing the query. So, if it returned FALSE, you could show the db error to the user(or log it somewhere). Otherwise, if it is TRUE, the query was executed successfully.

For reference: PDO Execute Statement

Upvotes: 0

xdazz
xdazz

Reputation: 160833

Error code with 00000 means the statement executed successfully.

Upvotes: 3

Related Questions