public function rowCount()
{
if ($this->result->state == ResultProxy::ROWS_FETCHED) {
return new Success(count($this->result->rows));
} else {
$deferred = new Deferred();
$this->result->deferreds[ResultProxy::ROWS_FETCHED][] = [$deferred, null, function () {
return count($this->result->rows);
}];
return $deferred->promise();
}
}