mirror of
https://github.com/nextcloud/server.git
synced 2026-04-20 22:00:39 -04:00
Rewrite query for numRows function for SELECT queries
This commit is contained in:
parent
427242cf32
commit
ee57ddd0b7
1 changed files with 8 additions and 1 deletions
|
|
@ -661,7 +661,14 @@ class DoctrineStatementWrapper {
|
|||
* provide numRows
|
||||
*/
|
||||
public function numRows() {
|
||||
return $this->statement->rowCount();
|
||||
$regex = '/^SELECT\s+(?:ALL\s+|DISTINCT\s+)?(?:.*?)\s+FROM\s+(.*)$/i';
|
||||
$queryString = $this->statement->getWrappedStatement()->queryString;
|
||||
if (preg_match($regex, $queryString, $output) > 0) {
|
||||
$query = OC_DB::prepare("SELECT COUNT(*) FROM {$output[1]}", PDO::FETCH_NUM);
|
||||
return $query->execute($this->lastArguments)->fetchColumn();
|
||||
}else{
|
||||
return $this->statement->rowCount();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue