Hack to reset PDO statement iterators after counting

pull/88/head
Thomas Bruederli 11 years ago committed by Thomas Bruederli
parent bd723e565d
commit b2c66d0331

@ -444,6 +444,7 @@ class rcube_db
*
* @param mixed $result Optional query handle
* @return mixed Number of rows or false on failure
* @deprecated This method shows very poor performance and should be avoided.
*/
public function num_rows($result = null)
{
@ -454,7 +455,9 @@ class rcube_db
return $query ? intval($query->fetchColumn(0)) : false;
}
else {
return count($result->fetchAll());
$num = count($result->fetchAll());
$result->execute(); // re-execute query because there's no seek(0)
return $num;
}
}

Loading…
Cancel
Save