From 6de6720c3e7a27b530ef7686ccf196acafbd0707 Mon Sep 17 00:00:00 2001 From: Juan Pablo Vial Date: Thu, 8 Sep 2022 17:41:21 -0400 Subject: [PATCH] MySQL Queries --- src/Database/Query/MySQL/Delete.php | 7 ++++ src/Database/Query/MySQL/Insert.php | 7 ++++ src/Database/Query/MySQL/Select.php | 50 +++++++++++++++++++++++++++++ src/Database/Query/MySQL/Update.php | 7 ++++ 4 files changed, 71 insertions(+) create mode 100644 src/Database/Query/MySQL/Delete.php create mode 100644 src/Database/Query/MySQL/Insert.php create mode 100644 src/Database/Query/MySQL/Select.php create mode 100644 src/Database/Query/MySQL/Update.php diff --git a/src/Database/Query/MySQL/Delete.php b/src/Database/Query/MySQL/Delete.php new file mode 100644 index 0000000..fbce5cd --- /dev/null +++ b/src/Database/Query/MySQL/Delete.php @@ -0,0 +1,7 @@ +setLimit($limit); + if ($offset !== null) { + $this->setOffset($offset); + } + return $this; + } + protected int $limit; + public function setLimit(int $limit): Select + { + $this->limit = $limit; + return $this; + } + public function getLimit(): int + { + return $this->limit; + } + protected int $offset; + public function setOffset(int $offset): Select + { + $this->offset = $offset; + return $this; + } + public function getOffset(): int + { + return $this->offset; + } + + public function build(): string + { + $query = [parent::build()]; + if (isset($this->limit)) { + $query []= 'LIMIT'; + $query []= $this->getLimit(); + if (isset($this->offset)) { + $query []= 'OFFSET'; + $query []= $this->getOffset(); + } + } + return implode(' ', $query); + } +} diff --git a/src/Database/Query/MySQL/Update.php b/src/Database/Query/MySQL/Update.php new file mode 100644 index 0000000..26bfa64 --- /dev/null +++ b/src/Database/Query/MySQL/Update.php @@ -0,0 +1,7 @@ +