summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIgor Scheller <igor.scheller@igorshp.de>2017-08-29 23:06:46 +0200
committerIgor Scheller <igor.scheller@igorshp.de>2017-08-29 23:16:41 +0200
commitd0074cf0069322fe175fb385b91c974fc2771547 (patch)
tree713fcb1f426c8a693938e3c8bbfc685e57f79e69 /src
parent50da458d8907cc7c05938565faa80b271bbf9b3d (diff)
parent581b81f1b25dc6b6f0a3b34810c293738fd40217 (diff)
Merge remote-tracking branch 'engelsystem/feature-igel-rewrite'
# Conflicts: # includes/controller/angeltypes_controller.php # includes/pages/admin_groups.php # includes/pages/user_settings.php # includes/sys_page.php # src/Exceptions/Handler.php # src/Http/Request.php
Diffstat (limited to 'src')
-rw-r--r--src/Database/Db.php29
-rw-r--r--src/Exceptions/Handler.php6
2 files changed, 26 insertions, 9 deletions
diff --git a/src/Database/Db.php b/src/Database/Db.php
index 4116ffda..777b16a2 100644
--- a/src/Database/Db.php
+++ b/src/Database/Db.php
@@ -79,19 +79,36 @@ class Db
return self::$stm->fetchAll(PDO::FETCH_ASSOC);
}
+
+ /**
+ * Run a select query and return only the first result or null if no result is found.
+ * @param string $query
+ * @param array $bindings
+ * @return array|null
+ */
+ public static function selectOne($query, array $bindings = [])
+ {
+ $result = self::select($query, $bindings);
+
+ if(empty($result)) {
+ return null;
+ }
+
+ return array_shift($result);
+ }
/**
* Run an insert query
*
* @param string $query
* @param array $bindings
- * @return int|bool
+ * @return int Row count
*/
public static function insert($query, array $bindings = [])
{
self::query($query, $bindings);
- return (self::$lastStatus ? self::$stm->rowCount() : false);
+ return self::$stm->rowCount();
}
/**
@@ -99,13 +116,13 @@ class Db
*
* @param string $query
* @param array $bindings
- * @return int|bool
+ * @return int
*/
public static function update($query, array $bindings = [])
{
self::query($query, $bindings);
- return (self::$lastStatus ? self::$stm->rowCount() : false);
+ return self::$stm->rowCount();
}
/**
@@ -113,13 +130,13 @@ class Db
*
* @param string $query
* @param array $bindings
- * @return int|bool
+ * @return int
*/
public static function delete($query, array $bindings = [])
{
self::query($query, $bindings);
- return (self::$lastStatus ? self::$stm->rowCount() : false);
+ return self::$stm->rowCount();
}
/**
diff --git a/src/Exceptions/Handler.php b/src/Exceptions/Handler.php
index 6e5b4749..c4fb639c 100644
--- a/src/Exceptions/Handler.php
+++ b/src/Exceptions/Handler.php
@@ -2,7 +2,7 @@
namespace Engelsystem\Exceptions;
-use Exception;
+use Throwable;
class Handler
{
@@ -40,9 +40,9 @@ class Handler
}
/**
- * @param Exception $e
+ * @param Throwable $e
*/
- public function exceptionHandler(Exception $e)
+ public function exceptionHandler(Throwable $e)
{
$this->handle(
'exception',