mirror of
https://github.com/Yubico/yubikey-val.git
synced 2025-02-21 15:54:15 +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)));
|
'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) {
|
private function query($query, $returnresult=false) {
|
||||||
if($this->dbh) {
|
if($this->dbh) {
|
||||||
$result = $this->dbh->query($query);
|
$this->result = $this->dbh->query($query);
|
||||||
if (! $result){
|
if (! $this->result){
|
||||||
error_log('Database error: ' . print_r($this->dbh->errorInfo(), true));
|
error_log('Database error: ' . print_r($this->dbh->errorInfo(), true));
|
||||||
error_log('Query was: ' . $query);
|
error_log('Query was: ' . $query);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ($returnresult) return $result;
|
if ($returnresult) return $this->result;
|
||||||
else return true;
|
else return true;
|
||||||
} else {
|
} else {
|
||||||
error_log('No database connection');
|
error_log('No database connection');
|
||||||
@ -374,7 +374,7 @@ or false on failure.
|
|||||||
*/
|
*/
|
||||||
public function rowCount()
|
public function rowCount()
|
||||||
{
|
{
|
||||||
if($this->dbh) return $this->dbh->rowCount();
|
if($this->result) return $this->result->rowCount();
|
||||||
else return 0;
|
else return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user