Commit 375b5338 authored by Sigrid Suski's avatar Sigrid Suski

(#) Fixes for latest MySQL version

parent fc061338
......@@ -31,6 +31,11 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
(!) Change
### 1.1.1 (September 2020)
(#) Fixes for latest MySQL version
### 1.1 (31 July 2020)
(+) Added support for WEBP images into Grafika
......
......@@ -17,7 +17,7 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* @created Wed, Nov 30, 2016 by Radek Suski
* @modified 20 May 2020 by Sigrid Suski
* @modified 28 August 2020 by Radek Suski
*/
namespace Sobi\Database;
......@@ -114,7 +114,7 @@ class MySQLi
}
/**
* Returns a database escaped string
* Returns a database escaped string.
*
* @param string $text string to be escaped
* @param bool $esc extra escaping
......@@ -127,7 +127,7 @@ class MySQLi
}
/**
* Returns a database escaped string
* Returns a database escaped string.
*
* @param string $text string to be escaped
* @param bool $esc extra escaping
......@@ -140,7 +140,7 @@ class MySQLi
}
/**
* Returns database null date format
* Returns database null date format.
*
* @return string Quoted null date string
*/
......@@ -156,11 +156,17 @@ class MySQLi
*
* @return MySQLi
*/
public function & setQuery( $sql )
public function & setQuery( $sql )
{
$sql = str_replace( 'spdb', $this->prefix . 'sobipro', $sql );
$sql = str_replace( 'NOW()', '\'' . gmdate( 'Y-m-d H:i:s' ) . '\'', $sql );
$this->db->setQuery( $sql );
try {
$this->db->setQuery( $sql );
}
catch ( \Exception $x ) {
exit( $x->getMessage() );
// throw new Exception( $e->getMessage() );
}
return $this;
}
......@@ -192,7 +198,7 @@ class MySQLi
}
/**
* Alias for select where $distinct is true
* Alias for select where $distinct is true.
*
* @param string | array $toSelect
* @param string | array $tables
......@@ -517,9 +523,7 @@ class MySQLi
* 'url' => 'unique'
* );
* SPFactory::db()->createTable( 'crawler', $fields, $keys, true, 'MyISAM' );
*
* Would create query like:
*
* CREATE TABLE IF NOT EXISTS `#__sobipro_crawler` (
* `url` VARCHAR(255) NOT NULL,
* `crid` INT(11) NOT NULL AUTO_INCREMENT,
......@@ -528,7 +532,6 @@ class MySQLi
* UNIQUE KEY `url` (`url`)
* ) ENGINE = MyISAM DEFAULT CHARSET = utf8;
*
*
* @param string $name - table name without any prefix
* @param array $fields - array with fields definition like: $fields[ 'url' ] = 'VARCHAR(255) NOT NULL';
* @param array $keys - optional array with keys defined like: $keys[ 'url' ] = 'unique'; || $keys[ 'url, crid' ] = 'primary';
......@@ -630,7 +633,7 @@ class MySQLi
}
/**
* Creates a "update" SQL query
* Creates a "update" SQL query.
*
* @param string $table - table to update
* @param array $set - two-dimensional array with table row name to update => new value
......@@ -653,11 +656,16 @@ class MySQLi
$state = str_replace( 'FUNCTION:', null, $state );
}
else {
if ( strlen( $state ) == 2 && $state == '++' ) {
$state = "{$var} + 1";
if ( ( strstr( $var, 'valid' ) || stristr( $var, 'time' ) ) && strlen( $state ) == 0 ) {
$state = '\'0000-00-00 00:00:00\'';
}
else {
$state = "'{$state}'";
if ( strlen( $state ) == 2 && $state == '++' ) {
$state = "{$var} + 1";
}
else {
$state = "'{$state}'";
}
}
}
$change[] = "{$var} = {$state}";
......@@ -668,7 +676,7 @@ class MySQLi
}
/**
* Creates a "replace" SQL query
* Creates a "replace" SQL query.
*
* @param string $table - table name
* @param array $values - two-dimensional array with table row name => value
......@@ -700,7 +708,7 @@ class MySQLi
}
/**
* Creates a "insert" SQL query
* Creates a "insert" SQL query.
*
* @param string $table - table name
* @param array $values - two-dimensional array with table row name => value
......@@ -741,7 +749,7 @@ class MySQLi
}
/**
* Fits a two dimensional array to the necessary columns of the given table
* Fits a two dimensional array to the necessary columns of the given table.
*
* @param string $table - table name
* @param array $values
......@@ -760,7 +768,7 @@ class MySQLi
}
/**
* Creates a "insert" SQL query with multiple values
* Creates a "insert" SQL query with multiple values.
*
* @param string $table - table name
* @param array $values - one-dimensional array with two-dimensional array with table row name => value
......@@ -809,7 +817,7 @@ class MySQLi
}
/**
* Creates a "insert" SQL query with update if cannot insert it because of duplicate primary key
* Creates a "insert" SQL query with update if cannot insert it because of duplicate primary key.
*
* @param string $table - table name
* @param array $values - two-dimensional array with table row name => value
......@@ -833,8 +841,13 @@ class MySQLi
$c[] = "{$var} = {$f}";
}
else {
$v[] = "'{$val}'";
$c[] = "{$var} = '{$val}'";
if ( ( strstr( $var, 'valid' ) || stristr( $var, 'time' ) ) && strlen( $val ) == 0 ) {
$v[] = '\'0000-00-00 00:00:00\'';
}
else {
$v[] = "'{$val}'";
$c[] = "{$var} = '{$val}'";
}
}
$k[] = "`{$var}`";
......@@ -853,7 +866,7 @@ class MySQLi
}
/**
* Returns current query
* Returns current query.
*
* @return string
*/
......@@ -863,7 +876,7 @@ class MySQLi
}
/**
* Returns queries counter
* Returns queries counter.
*
* @return int
*/
......@@ -873,7 +886,7 @@ class MySQLi
}
/**
* Execute the query
* Execute the query.
*
* @return mixed database resource or <var>false</var>.
*/
......@@ -904,7 +917,7 @@ class MySQLi
}
/**
* Load an array of single field results into an array
* Loads an array of single field results into an array.
*
* @return array
* @throws Exception
......@@ -923,7 +936,7 @@ class MySQLi
}
/**
* Load a assoc list of database rows
* Loads a assoc list of database rows.
*
* @param string $key field name of a primary key
*
......@@ -944,7 +957,7 @@ class MySQLi
}
/**
* Loads the first row of a query into an object
* Loads the first row of a query into an object.
*
* @return stdObject
* @throws Exception
......@@ -971,7 +984,7 @@ class MySQLi
}
/**
* Load a list of database objects
* Loads a list of database objects.
*
* @param string $key
*
......@@ -992,7 +1005,7 @@ class MySQLi
}
/**
* Load the first row of the query.
* Loads the first row of the query.
*
* @return array
* @throws Exception
......@@ -1011,7 +1024,7 @@ class MySQLi
}
/**
* Load a list of database rows (numeric column indexing)
* Loads a list of database rows (numeric column indexing).
*
* @param string $key field name of a primary key
*
......@@ -1032,7 +1045,8 @@ class MySQLi
}
/**
* Returns an error statement
* Returns an error statement.
*
* @return string
* @deprecated
*/
......@@ -1042,7 +1056,7 @@ class MySQLi
}
/**
* Returns the ID generated from the previous insert operation
* Returns the ID generated from the previous insert operation.
*
* @return int
*/
......@@ -1052,7 +1066,7 @@ class MySQLi
}
/**
* executing query (update/insert etc)
* executing query (update/insert etc).
*
* @param string $query - query to execute
*
......@@ -1073,7 +1087,7 @@ class MySQLi
}
/**
* Returns all rows of given table
* Returns all rows of given table.
*
* @param string $table
*
......@@ -1115,7 +1129,7 @@ class MySQLi
*/
public function transaction()
{
return $this->exec( 'START TRANSACTION;' ) !== false ? true : false;
return true;//$this->exec( 'START TRANSACTION;' ) !== false ? true : false;
}
/**
......@@ -1186,7 +1200,7 @@ class MySQLi
}
/**
* Creates syntax to check the expiration date, state, and start publishing date off an row
* Creates syntax to check the expiration date, state, and start publishing date off an row.
*
* @param string $until - row name where the expiration date is stored
* @param string $since - row name where the start date is stored
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment