database object, it is recommended you use the quote method directly. * * Note that 'q' is an alias for this method as it is in DatabaseDriver. * * Usage: * $query->quote('fulltext'); * $query->q('fulltext'); * $query->q(array('option', 'fulltext')); * * @param array|string $text A string or an array of strings to quote. * @param boolean $escape True (default) to escape the string, false to leave it unchanged. * * @return string The quoted input string. * * @since 2.0.0 * @throws \RuntimeException if the internal db property is not a valid object. */ abstract public function quote($text, $escape = true); /** * Get the regular expression operator * * Usage: * $query->where('field ' . $query->regexp($search)); * * @param string $value The regex pattern. * * @return string * * @since 2.0.0 */ public function regexp($value) { return ' REGEXP ' . $value; } /** * Get the function to return a random floating-point value * * Usage: * $query->rand(); * * @return string * * @since 2.0.0 */ public function rand() { return ' RAND() '; } /** * Find a value in a varchar used like a set. * * Ensure that the value is an integer before passing to the method. * * Usage: * $query->findInSet((int) $parent->id, 'a.assigned_cat_ids') * * @param string $value The value to search for. * @param string $set The set of values. * * @return string A representation of the MySQL find_in_set() function for the driver. * * @since 2.0.0 */ public function findInSet($value, $set) { return ' find_in_set(' . $value . ', ' . $set . ')'; } /** * Return the number of the current row. * * Usage: * $query->select('id'); * $query->selectRowNumber('ordering,publish_up DESC', 'new_ordering'); * $query->from('#__content'); * * @param string $orderBy An expression of ordering for window function. * @param string $orderColumnAlias An alias for new ordering column. * * @return $this * * @since 2.0.0 * @throws \RuntimeException * * @todo Remove this method when the database version requirements have been raised * to >= 8.0.0 for MySQL and >= 10.2.0 for MariaDB so the ROW_NUMBER() window * function can be used in any case. */ public function selectRowNumber($orderBy, $orderColumnAlias) { /** @var MysqlDriver $db */ $db = $this->db; // Use parent method with ROW_NUMBER() window function on MariaDB >= 10.2.0 and MySQL >= 8.0.0. if (version_compare($db->getVersion(), $db->isMariaDb() ? '10.2.0' : '8.0.0', '>=')) { return parent::selectRowNumber($orderBy, $orderColumnAlias); } $this->validateRowNumber($orderBy, $orderColumnAlias); return $this->select("(SELECT @rownum := @rownum + 1 FROM (SELECT @rownum := 0) AS r) AS $orderColumnAlias"); } /** * Casts a value to a char. * * Ensure that the value is properly quoted before passing to the method. * * Usage: * $query->select($query->castAs('CHAR', 'a')); * * @param string $type The type of string to cast as. * @param string $value The value to cast as a char. * @param string $length The value to cast as a char. * * @return string SQL statement to cast the value as a char type. * * @since 1.0 */ public function castAs(string $type, string $value, ?string $length = null) { switch (strtoupper($type)) { case 'CHAR': if (!$length) { return $value; } else { return 'CAST(' . $value . ' AS CHAR(' . $length . '))'; } // No break case 'INT': return '(' . $value . ' + 0)'; } return parent::castAs($type, $value, $length); } }
The server returned a "500 - Whoops, looks like something went wrong."