Commit 72b6e456 authored by Taddeus Kroes's avatar Taddeus Kroes

Added result_count method to SQL plugin.

parent 1d53c44e
......@@ -140,6 +140,20 @@ class pQuerySql extends pQuery implements pQueryExtension {
return $this;
}
/**
* Find the number of resulting rows of the current query.
*
* @returns int The number of rows.
*/
function result_count() {
$this->assert_execution();
if( !$this->result )
return 0;
return mysql_num_rows($this->result);
}
/**
* Fetch a row from the current result.
*
......
......@@ -53,8 +53,14 @@ class pQuerySqlTest extends UnitTestCase {
function test_select_simple() {
$sql = _sql("select bar from foo where id = 1");
$results = $sql->fetch_all('object');
$this->assertEqual($results[0]->bar, 'test1');
$result = $sql->fetch('object');
$this->assertEqual($result->bar, 'test1');
$this->assertIdentical($sql->fetch(), false);
}
function test_result_count() {
$sql = _sql("select bar from foo where id in (1, 2)");
$this->assertEqual($sql->result_count(), 2);
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment