From 1ff5c35de5dbd70a782875a91dd2232fd01b002b Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 14:38:04 +0200 Subject: Adding upstream version 0.10.1. Signed-off-by: Daniel Baumann --- vendor/ipl/sql/src/Update.php | 100 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 vendor/ipl/sql/src/Update.php (limited to 'vendor/ipl/sql/src/Update.php') diff --git a/vendor/ipl/sql/src/Update.php b/vendor/ipl/sql/src/Update.php new file mode 100644 index 0000000..356a610 --- /dev/null +++ b/vendor/ipl/sql/src/Update.php @@ -0,0 +1,100 @@ +table; + } + + /** + * Set the table for the UPDATE query + * + * Note that this method does NOT quote the table you specify for the UPDATE. + * If you allow user input here, you must protected yourself against SQL injection using + * {@link Connection::quoteIdentifier()} for the table names passed to this method. + * If you are using special table names, e.g. reserved keywords for your DBMS, you are required to use + * {@link Connection::quoteIdentifier()} as well. + * + * @param string|array $table The table to update. The table specification must be in one of the + * following formats: 'table', 'table alias', ['alias' => 'table'] + * + * @return $this + */ + public function table($table) + { + $this->table = is_array($table) ? $table : [$table]; + + return $this; + } + + /** + * Get the columns to update in terms of column-value pairs + * + * @return array|null + */ + public function getSet() + { + return $this->set; + } + + /** + * Set the columns to update in terms of column-value pairs + * + * Values may either be plain or expressions or scalar subqueries. + * + * Note that this method does NOT quote the columns you specify for the UPDATE. + * If you allow user input here, you must protected yourself against SQL injection using + * {@link Connection::quoteIdentifier()} for the column names passed to this method. + * If you are using special column names, e.g. reserved keywords for your DBMS, you are required to use + * {@link Connection::quoteIdentifier()} as well. + * + * @param iterable $set Associative set of column-value pairs + * + * @return $this + * + * @throws InvalidArgumentException If set type is invalid + */ + public function set($set) + { + $this->set = arrayval($set); + + return $this; + } + + public function __clone() + { + $this->cloneCte(); + $this->cloneWhere(); + + foreach ($this->set as &$value) { + if ($value instanceof ExpressionInterface || $value instanceof Select) { + $value = clone $value; + } + } + unset($value); + } +} -- cgit v1.2.3