Reputation: 65
I am PDO newbie and i dont know how to catch error's or see what wrong anyway look at this code :
Call The Function here :
$this->storage->updateTriplet($cookieValues[0],$newToken.$this->salt, $cookieValues[2].$this->salt, $t, $expire);
The problem function :
public function updateTriplet($credential, $token, $persistentToken,$t, $expire=0) {
$sql = "UPDATE {$this->tableName}
SET cred=?, tok=?, ptok=?, t=?, expires=?
WHERE ptok=?'".$persistentToken."' ";
$query = $this->connection->prepare($sql);
$query->execute(array($credential ,$token, $persistentToken , $t , date("Y-m-d H:i:s", $expire)));
}
And that the good function ,insert function i using :
public function storeTriplet($credential, $token, $persistentToken,$t, $expire=0) {
$sql = "INSERT INTO {$this->tableName}({$this->credentialColumn}, " .
"{$this->tokenColumn}, {$this->persistentTokenColumn}, " .
"{$this->t},{$this->expiresColumn}) VALUES(?, SHA1(?), SHA1(?),?, ?)";
$query = $this->connection->prepare($sql);
$query->execute(array($credential, $token, $persistentToken,$t, date("Y-m-d H:i:s", $expire)));
}
Anyway my insert function working perfect the problem is on the Update Function first one ,my update function not working , any one know where is my problem and what i am doing wrong ? and how to see the MySql PDO error's on the Update Function ?
Updated : answered and fix :
public function updateTriplet($credential, $token, $persistentToken,$t, $expire=0) {
$sql = "UPDATE {$this->tableName}
SET cred=?, tok=?, ptok=?, t=?, expires=?
WHERE ptok=SHA1('".$persistentToken."');
$query = $this->connection->prepare($sql);
$query->execute(array($credential ,$token, $persistentToken , $t , date("Y-m-d H:i:s", $expire)));
}
Thanks so much.
Upvotes: 2
Views: 1039
Reputation: 2643
It seems that you missed to provied ptok
parameter.
$sql = "UPDATE {$this->tableName}
SET cred=?, tok=?, ptok=?, t=?, expires=?
WHERE ptok=?";
$query->execute(array($credential ,$token, $persistentToken ,
$t , date("Y-m-d H:i:s", $expire), $ptok));
// ^______ Add this variable
Upvotes: 1