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@A@y¥4~@}V~@Dxp~@N׵~@6U~@>~@EX@".@~@~@ka~@\@]Y{@)@/$~@A~@ C~@~@OĈy~@ߢR~@f~@q&~@ x~@~K~@wB~@]~@6k2@Bs~@hY-@rgo~@@w,@)mxh)@H@*>@]@^,@jR@@@+n}@037SA@H@z3E@Tj~@U@r(@9m~@D@}A@@@@?cE@ q@6̰,@)@(2@{@@3@p@eger $intRows The maximum number of rows * @param integer $intOffset The number of rows to skip * * @return Statement The statement object */ public function limit($intRows, $intOffset=0) { if ($intRows <= 0) { $intRows = 30; } if ($intOffset < 0) { $intOffset = 0; } if (strncasecmp($this->strQuery, 'SELECT', 6) === 0) { $this->strQuery .= ' LIMIT ' . $intOffset . ',' . $intRows; } else { $this->strQuery .= ' LIMIT ' . $intRows; } return $this; } /** * Execute the query and return the result object * * @return Result The result object */ public function execute() { $arrParams = \func_get_args(); if (\count($arrParams) === 1 && \is_array($arrParams[0])) { trigger_deprecation('contao/core-bundle', '4.13', 'Using "%s()" with an array parameter has been deprecated and will no longer work in Contao 5.0. Use argument unpacking via ... instead."', __METHOD__); $arrParams = array_values($arrParams[0]); } return $this->query('', array_merge($this->arrSetParams, $arrParams)); } /** * Directly send a query string to the database * * @param string $strQuery The query string * * @return Result|Statement The result object or the statement object if there is no result set * * @throws \Exception If the query string is empty */ public function query($strQuery='', array $arrParams = array(), array $arrTypes = array()) { if (!empty($strQuery)) { $this->strQuery = trim($strQuery); } // Make sure there is a query string if (!$this->strQuery) { throw new \Exception('Empty query string'); } foreach ($arrParams as $key => $varParam) { // Automatically set type to boolean when no type is defined, // otherwise "false" will be converted to an empty string. if (null === ($arrTypes[$key] ?? null)) { $arrTypes[$key] = \is_bool($varParam) ? ParameterType::BOOLEAN : ParameterType::STRING; } if (\is_string($varParam) || \is_bool($varParam) || \is_float($varParam) || \is_int($varParam) || $varParam === null) { continue; } $arrParams[$key] = serialize($varParam); } $this->arrLastUsedParams = $arrParams; // Execute the query // TODO: remove the try/catch block in Contao 5.0 try { $this->statement = $this->resConnection->executeQuery($this->strQuery, $arrParams, $arrTypes); } catch (DriverException|\ArgumentCountError $exception) { // SQLSTATE[HY000]: This command is not supported in the prepared statement protocol if ($exception->getCode() === 1295) { $this->resConnection->executeStatement($this->strQuery, $arrParams, $arrTypes); trigger_deprecation('contao/core-bundle', '4.13', 'Using "%s()" for statements (instead of queries) has been deprecated and will no longer work in Contao 5.0. Use "%s::executeStatement()" instead.', __METHOD__, Connection::class); return $this; } if (!$arrParams) { throw $exception; } $intTokenCount = substr_count(preg_replace("/('[^']*')/", '', $this->strQuery), '?'); if (\count($arrParams) <= $intTokenCount) { throw $exception; } // If we get here, there are more parameters than tokens, so we slice the array and try to execute the query again $this->statement = $this->resConnection->executeQuery($this->strQuery, \array_slice($arrParams, 0, $intTokenCount), $arrTypes); // Only trigger the deprecation if the parameter count was the reason for the exception and the previous call did not throw if ($this->arrLastUsedParams === array(null)) { trigger_deprecation('contao/core-bundle', '4.13', 'Using "%s::execute(null)" has been deprecated and will no longer work in Contao 5.0. Omit the NULL parameters instead.', __CLASS__); } else { trigger_deprecation('contao/core-bundle', '4.13', 'Passing more parameters than "?" tokens has been deprecated and will no longer work in Contao 5.0. Use the correct number of parameters instead.'); } } // No result set available if ($this->statement->columnCount() < 1) { return $this; } // Instantiate a result object return new Result($this->statement, $this->strQuery); } /** * Replace the wildcards in the query string * * @param array $arrValues The values array * * @throws \Exception If $arrValues has too few values to replace the wildcards in the query string * * @deprecated Deprecated since Contao 4.13, to be removed in Contao 5.0. */ protected function replaceWildcards($arrValues) { trigger_deprecation('contao/core-bundle', '4.13', 'Using "%s()" has been deprecated and will no longer work in Contao 5.0.', __METHOD__); $arrValues = $this->escapeParams($arrValues); $this->strQuery = preg_replace('/(?strQuery); // Replace wildcards if (!$this->strQuery = @vsprintf($this->strQuery, $arrValues)) { throw new \Exception('Too few arguments to build the query string'); } } /** * Escape the values and serialize objects and arrays * * @param array $arrValues The values array * * @return array The array with the escaped values * * @deprecated Deprecated since Contao 4.13, to be removed in Contao 5.0. */ protected function escapeParams($arrValues) { trigger_deprecation('contao/core-bundle', '4.13', 'Using "%s()" has been deprecated and will no longer work in Contao 5.0.', __METHOD__); foreach ($arrValues as $k=>$v) { switch (\gettype($v)) { case 'string': $arrValues[$k] = $this->resConnection->quote($v); break; case 'boolean': $arrValues[$k] = ($v === true) ? 1 : 0; break; case 'object': case 'array': $arrValues[$k] = $this->resConnection->quote(serialize($v)); break; default: $arrValues[$k] = $v ?? 'NULL'; break; } } return $arrValues; } /** * Explain the current query * * @return string The explanation string * * @deprecated Deprecated since Contao 4.13, to be removed in Contao 5.0. */ public function explain() { trigger_deprecation('contao/core-bundle', '4.13', 'Using "%s()" has been deprecated and will no longer work in Contao 5.0.', __METHOD__); return $this->resConnection->fetchAssociative('EXPLAIN ' . $this->strQuery, $this->arrLastUsedParams); } /** * Bypass the cache and always execute the query * * @return Result The result object * * @deprecated Deprecated since Contao 4.0, to be removed in Contao 5.0. * Use Statement::execute() instead. */ public function executeUncached() { trigger_deprecation('contao/core-bundle', '4.0', 'Using "Contao\Statement::executeUncached()" has been deprecated and will no longer work in Contao 5.0. Use "Contao\Statement::execute()" instead.'); return \call_user_func_array(array($this, 'execute'), \func_get_args()); } /** * Always execute the query and add or replace an existing cache entry * * @return Result The result object * * @deprecated Deprecated since Contao 4.0, to be removed in Contao 5.0. * Use Statement::execute() instead. */ public function executeCached() { trigger_deprecation('contao/core-bundle', '4.0', 'Using "Contao\Statement::executeCached()" has been deprecated and will no longer work in Contao 5.0. Use "Contao\Statement::execute()" instead.'); return \call_user_func_array(array($this, 'execute'), \func_get_args()); } } class_alias(Statement::class, 'Database\Statement');