From b68ef6e73547be686355e4c26037206c97162d51 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 24 Apr 2017 15:46:01 +0200 Subject: [inc/Database] Add ::queryAll() --- inc/database.inc.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'inc') diff --git a/inc/database.inc.php b/inc/database.inc.php index f3a90fe7..9153c688 100644 --- a/inc/database.inc.php +++ b/inc/database.inc.php @@ -53,6 +53,20 @@ class Database return $res->fetch(PDO::FETCH_ASSOC); } + /** + * If you need all rows for a query as plain array you can use this. + * Don't use this if you want to do further processing of the data, to save some + * memory. + * + * @return array|bool List of associative arrays representing rows, or false on error + */ + public static function queryAll($query, $args = array(), $ignoreError = false) + { + $res = self::simpleQuery($query, $args, $ignoreError); + if ($res === false) + return false; + return $res->fetchAll(PDO::FETCH_ASSOC); + } /** * Execute the given query and return the number of rows affected. -- cgit v1.2.3-55-g7522