implement pexecute_first to PDO database class to return a result right away

Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann (d00p)
2013-11-06 10:51:50 +01:00
parent 2e42ef2043
commit 94a5edc1eb

View File

@@ -69,6 +69,22 @@ class Database {
}
}
/**
* Wrapper for PDOStatement::execute so we can catch the PDOException
* and display the error nicely on the panel - also fetches the
* result from the statement and returns the resulting array
*
* @param PDOStatement $stmt
* @param array $params (optional)
* @param bool $showerror suppress errordisplay (default true)
*
* @return array
*/
public static function pexecute_first(&$stmt, $params = null, $showerror = true) {
self::pexecute($stmt, $params, $showerror);
return $stmt->fetch(PDO::FETCH_ASSOC);
}
/**
* returns the number of found rows of the last select query
*