From 65c79ffc29b910e49d8234dcf896cbf77304f0e7 Mon Sep 17 00:00:00 2001 From: "Bruno O. Notario" Date: Fri, 8 Mar 2024 17:31:50 -0300 Subject: [PATCH] Update MagiQL Insert writer --- .../Syntax/Adapt/SQLite3/ColumnWriter.php | 27 ++++++++++++++ .../Syntax/Adapt/SQLite3/InsertWriter.php | 37 +++++++++++++++++++ system/MagiQL/Manipulation/JoinQuery.php | 2 +- system/MagiQL/Manipulation/Select.php | 22 ++++++++++- 4 files changed, 86 insertions(+), 2 deletions(-) create mode 100644 system/MagiQL/Builder/Syntax/Adapt/SQLite3/ColumnWriter.php create mode 100644 system/MagiQL/Builder/Syntax/Adapt/SQLite3/InsertWriter.php diff --git a/system/MagiQL/Builder/Syntax/Adapt/SQLite3/ColumnWriter.php b/system/MagiQL/Builder/Syntax/Adapt/SQLite3/ColumnWriter.php new file mode 100644 index 0000000..a12280c --- /dev/null +++ b/system/MagiQL/Builder/Syntax/Adapt/SQLite3/ColumnWriter.php @@ -0,0 +1,27 @@ +writer->writeColumnName($column); + + return $columnString; + } +} diff --git a/system/MagiQL/Builder/Syntax/Adapt/SQLite3/InsertWriter.php b/system/MagiQL/Builder/Syntax/Adapt/SQLite3/InsertWriter.php new file mode 100644 index 0000000..43c918f --- /dev/null +++ b/system/MagiQL/Builder/Syntax/Adapt/SQLite3/InsertWriter.php @@ -0,0 +1,37 @@ +writer = $writer; + $this->columnWriter = new ColumnWriter($this->writer, $placeholder); + } + + /** + * @param $columns + * + * @return string + */ + protected function writeQueryColumns($columns) + { + return $this->writeCommaSeparatedValues($columns, $this->columnWriter, 'writeColumnWithoutTable'); + } +} diff --git a/system/MagiQL/Manipulation/JoinQuery.php b/system/MagiQL/Manipulation/JoinQuery.php index aae91d0..f89b7e4 100644 --- a/system/MagiQL/Manipulation/JoinQuery.php +++ b/system/MagiQL/Manipulation/JoinQuery.php @@ -80,7 +80,7 @@ class JoinQuery { return $this->join($table, $selfColumn, $refColumn, $columns, self::JOIN_LEFT); } - + /** * @param string $table * @param mixed $selfColumn diff --git a/system/MagiQL/Manipulation/Select.php b/system/MagiQL/Manipulation/Select.php index c41193f..43605c1 100644 --- a/system/MagiQL/Manipulation/Select.php +++ b/system/MagiQL/Manipulation/Select.php @@ -257,6 +257,16 @@ class Select extends AbstractBaseQuery { return $this->columnQuery->setColumns($columns); } + + /** + * Sets the all columns used to write the SELECT statement. + * + * @return ColumnQuery + */ + public function setAllColumns() + { + return $this->setColumns([\Phacil\Framework\MagiQL\Syntax\Column::ALL]); + } /** * Allows setting a Select query as a column value. @@ -381,7 +391,7 @@ class Select extends AbstractBaseQuery /** * @param int $start - * @param int $count + * @param int $count * * @return $this */ @@ -393,6 +403,16 @@ class Select extends AbstractBaseQuery return $this; } + /** + * @param int $count + * @return $this + */ + public function offset($count) { + $this->limitCount = (int)$count; + + return $this; + } + /** * @return array */