summaryrefslogtreecommitdiff
path: root/src/Database/Database.php
diff options
context:
space:
mode:
authorIgor Scheller <igor.scheller@igorshp.de>2018-09-30 19:31:14 +0200
committerIgor Scheller <igor.scheller@igorshp.de>2018-09-30 19:33:14 +0200
commitb46207f91176cf944284c01c213d3f69075377a4 (patch)
tree3d04a46c84c8b66b2d5a56a851249fde80257e28 /src/Database/Database.php
parent6187eed3bb08f200050a3078bd762b5731dfbe78 (diff)
parent0b0890f425ced27b2204a046296de4cccdac4eb8 (diff)
Merge remote-tracking branch 'MyIgel/session'
Diffstat (limited to 'src/Database/Database.php')
-rw-r--r--src/Database/Database.php98
1 files changed, 98 insertions, 0 deletions
diff --git a/src/Database/Database.php b/src/Database/Database.php
new file mode 100644
index 00000000..407a8bf9
--- /dev/null
+++ b/src/Database/Database.php
@@ -0,0 +1,98 @@
+<?php
+
+namespace Engelsystem\Database;
+
+use Illuminate\Database\Connection as DatabaseConnection;
+use PDO;
+
+class Database
+{
+ /** @var DatabaseConnection */
+ protected $connection;
+
+ /**
+ * @param DatabaseConnection $connection
+ */
+ public function __construct(DatabaseConnection $connection)
+ {
+ $this->connection = $connection;
+ }
+
+ /**
+ * Run a select query
+ *
+ * @param string $query
+ * @param array $bindings
+ * @return object[]
+ */
+ public function select($query, array $bindings = [])
+ {
+ return $this->connection->select($query, $bindings);
+ }
+
+ /**
+ * Run a select query and return only the first result or null if no result is found.
+ *
+ * @param string $query
+ * @param array $bindings
+ * @return object|null
+ */
+ public function selectOne($query, array $bindings = [])
+ {
+ return $this->connection->selectOne($query, $bindings);
+ }
+
+ /**
+ * Run an insert query
+ *
+ * @param string $query
+ * @param array $bindings
+ * @return bool
+ */
+ public function insert($query, array $bindings = [])
+ {
+ return $this->connection->insert($query, $bindings);
+ }
+
+ /**
+ * Run an update query
+ *
+ * @param string $query
+ * @param array $bindings
+ * @return int
+ */
+ public function update($query, array $bindings = [])
+ {
+ return $this->connection->update($query, $bindings);
+ }
+
+ /**
+ * Run a delete query
+ *
+ * @param string $query
+ * @param array $bindings
+ * @return int
+ */
+ public function delete($query, array $bindings = [])
+ {
+ return $this->connection->delete($query, $bindings);
+ }
+
+ /**
+ * Get the PDO instance
+ *
+ * @return PDO
+ */
+ public function getPdo()
+ {
+ return $this->connection->getPdo();
+ }
+
+ /**
+ * @return DatabaseConnection
+ */
+ public function getConnection()
+ {
+ return $this->connection;
+ }
+}