0
votes

For security purposes, I set ATTR_EMULATE_PREPARES option to false. And in development environment, ATTR_ERRMODE is on ERRMODE_EXCEPTION.

But this code :

// $this->bdd is juste a regular PDO instance with some options
$req = $this->bdd->prepare('INSERT INTO users VALUES(NULL, :login, :passwd, :email, :firstname, :lastname, :role, :token_id, :confirmed, :registration_date, :last_connexion_date)');

$req->bindValue(':login', $login, PDO::PARAM_STR);
$req->bindValue(':passwd', $passwd, PDO::PARAM_STR);
$req->bindValue(':email', $email, PDO::PARAM_STR);
$req->bindValue(':firstname', $firstname, PDO::PARAM_STR);
$req->bindValue(':lastname', $lastname, PDO::PARAM_STR);
$req->bindValue(':role', $role, PDO::PARAM_INT);
$req->bindValue(':token_id', $token_id, PDO::PARAM_INT);
$req->bindValue(':confirmed', $confirmed, PDO::PARAM_BOOL);
$req->bindValue(':registration_date', $registration_date, PDO::PARAM_STR);
$req->bindValue(':last_connexion_date', $last_connexion_date, PDO::PARAM_STR);

return $req->execute() ? true : $req->errorInfo();

just fails silently, with in an errCode to 00000. While browsing stackoverflow and other platforms, I found some similar bugs related to "truly prepared statement" which can be solved (doesn't work for me). I decided to turn on emulation, and it worked perfectly.

My problem : I want to keep truly prepared statements, and I don't know, what's wrong...

EDIT : I just change from PDO to MySQLi for test purposes, MySQLi works, PDO don't (and still fails siltenty) here the scripts :

http://pastebin.com/jvjsfFVC

MySQLi always does truly prepared statement

1

1 Answers

0
votes

Have the try catch between your code that way if we run into errors we can see the error array instead of blank.

 try {
    $req = $this->bdd->prepare('INSERT INTO users VALUES(NULL, :login, :passwd, :email, :firstname, :lastname, :role, :token_id, :confirmed, :registration_date, :last_connexion_date)');

    $req->bindValue(':login', $login, PDO::PARAM_STR);
    $req->bindValue(':passwd', $passwd, PDO::PARAM_STR);
    $req->bindValue(':email', $email, PDO::PARAM_STR);
    $req->bindValue(':firstname', $firstname, PDO::PARAM_STR);
    $req->bindValue(':lastname', $lastname, PDO::PARAM_STR);
    $req->bindValue(':role', $role, PDO::PARAM_INT);
    $req->bindValue(':token_id', $token_id, PDO::PARAM_INT);
    $req->bindValue(':confirmed', $confirmed, PDO::PARAM_BOOL);
    $req->bindValue(':registration_date', $registration_date, PDO::PARAM_STR);
    $req->bindValue(':last_connexion_date', $last_connexion_date, PDO::PARAM_STR);
$execute = $req->execute();
 } catch (PDOException $error) {
print_r($error);
die();


}