mirror of
https://github.com/Yubico/yubikey-val.git
synced 2025-02-20 21:54:20 +01:00
corrected. Rowcount acts on last statement result rather on db
This commit is contained in:
parent
d896a8c2d9
commit
10d6f5e4ec
@ -75,5 +75,13 @@ class DbTest extends PHPUnit_Framework_TestCase
|
||||
'value2'=>200)));
|
||||
|
||||
}
|
||||
|
||||
public function testRowCount()
|
||||
{
|
||||
$this->assertTrue($this->db->save('unittest', array('value1'=>100,
|
||||
'value2'=>200,
|
||||
'id'=>1)));
|
||||
$this->assertEquals(1, $this->db->rowCount(), "1 row should have been affected by previous statement");
|
||||
}
|
||||
}
|
||||
?>
|
@ -130,13 +130,13 @@ class Db
|
||||
|
||||
private function query($query, $returnresult=false) {
|
||||
if($this->dbh) {
|
||||
$result = $this->dbh->query($query);
|
||||
if (! $result){
|
||||
$this->result = $this->dbh->query($query);
|
||||
if (! $this->result){
|
||||
error_log('Database error: ' . print_r($this->dbh->errorInfo(), true));
|
||||
error_log('Query was: ' . $query);
|
||||
return false;
|
||||
}
|
||||
if ($returnresult) return $result;
|
||||
if ($returnresult) return $this->result;
|
||||
else return true;
|
||||
} else {
|
||||
error_log('No database connection');
|
||||
@ -374,7 +374,7 @@ or false on failure.
|
||||
*/
|
||||
public function rowCount()
|
||||
{
|
||||
if($this->dbh) return $this->dbh->rowCount();
|
||||
if($this->result) return $this->result->rowCount();
|
||||
else return 0;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user