aboutsummaryrefslogtreecommitdiff
path: root/bootstrap/database/QueryBuilder.php
diff options
context:
space:
mode:
authorThedro Neely <thedroneely@gmail.com>2018-08-30 04:40:53 -0400
committerThedro Neely <thedroneely@gmail.com>2018-08-30 04:40:53 -0400
commit2659205908bd5cab508f4ff817123673e078ab74 (patch)
treee455f36b124e9b98f7005e6d4310b71881734623 /bootstrap/database/QueryBuilder.php
downloadedwinmattiacci.com-2659205908bd5cab508f4ff817123673e078ab74.tar.gz
edwinmattiacci.com-2659205908bd5cab508f4ff817123673e078ab74.tar.bz2
edwinmattiacci.com-2659205908bd5cab508f4ff817123673e078ab74.zip
Initialize Repo: First Commit
Diffstat (limited to 'bootstrap/database/QueryBuilder.php')
-rw-r--r--bootstrap/database/QueryBuilder.php31
1 files changed, 31 insertions, 0 deletions
diff --git a/bootstrap/database/QueryBuilder.php b/bootstrap/database/QueryBuilder.php
new file mode 100644
index 0000000..a814ed3
--- /dev/null
+++ b/bootstrap/database/QueryBuilder.php
@@ -0,0 +1,31 @@
+<?php
+
+class QueryBuilder
+{
+ protected $pdo;
+
+ public function __construct($pdo)
+ {
+ $this->pdo = $pdo;
+ }
+
+ public function selectAll($table, $intoClass)
+ {
+ $statement = $this->pdo->prepare("select * from {$table}");
+ $statement->execute();
+ return $statement->fetchAll(PDO::FETCH_CLASS, $intoClass);
+ }
+
+ public function insert($table, $data)
+ {
+ $sql = sprintf(
+ 'insert into %s (%s) values (%s)',
+ $table,
+ implode(', ', array_keys($data)),
+ ':' . implode(', :', array_keys($data))
+ );
+
+ $statment = $this->pdo->prepare($sql);
+ $statment->execute($data);
+ }
+}