Vergleich inc/db_sqlite.php - 1.8.30 - 1.8.36

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 65Zeile 65
	 * @var resource
*/
public $link;

	 * @var resource
*/
public $link;

 

/**
* @var array
*/
public $connections = array();


/**
* Explanation of a query.


/**
* Explanation of a query.

Zeile 293Zeile 298

/**
* Execute a write query on the database


/**
* Execute a write query on the database

	 *

	 *

	 * @param string $query The query SQL.
* @param boolean|int $hide_errors 1 if hide errors, 0 if not.
* @return PDOStatement The query data.

	 * @param string $query The query SQL.
* @param boolean|int $hide_errors 1 if hide errors, 0 if not.
* @return PDOStatement The query data.

Zeile 336Zeile 341
			return $array[$field];
}
return null;

			return $array[$field];
}
return null;

	}

	}


/**
* Moves internal row pointer to the next row


/**
* Moves internal row pointer to the next row

Zeile 364Zeile 369
				$result = false;
}
}

				$result = false;
}
}





		return $result;

		return $result;

	}


	}


	/**
* Return the number of rows resulting from a query.
*

	/**
* Return the number of rows resulting from a query.
*

Zeile 377Zeile 382
	function num_rows($query)
{
return $this->db->num_rows($query);

	function num_rows($query)
{
return $this->db->num_rows($query);

	}


	}


	/**
* Return the last id number of inserted data.
*

	/**
* Return the last id number of inserted data.
*

Zeile 392Zeile 397

/**
* Close the connection with the DBMS.


/**
* Close the connection with the DBMS.

	 *

	 *

	 */
function close()
{

	 */
function close()
{

Zeile 406Zeile 411
	 * @return int The error number of the current error.
*/
function error_number($query=null)

	 * @return int The error number of the current error.
*/
function error_number($query=null)

	{

	{

		if($query == null)
{
$query = $this->db->last_query;

		if($query == null)
{
$query = $this->db->last_query;

Zeile 477Zeile 482
					require_once MYBB_ROOT."inc/class_error.php";
$error_handler = new errorHandler();
}

					require_once MYBB_ROOT."inc/class_error.php";
$error_handler = new errorHandler();
}





				$error = array(
"error_no" => $error_no,
"error" => $error,
"query" => $string
);
$error_handler->error(MYBB_SQL, $error);

				$error = array(
"error_no" => $error_no,
"error" => $error,
"query" => $string
);
$error_handler->error(MYBB_SQL, $error);

			}

			}

			else
{
trigger_error("<strong>[SQL] [{$error_no}] {$error}</strong><br />{$string}", E_USER_ERROR);
}

			else
{
trigger_error("<strong>[SQL] [{$error_no}] {$error}</strong><br />{$string}", E_USER_ERROR);
}

		}
}


		}
}


	/**
* Returns the number of affected rows in a query.
*

	/**
* Returns the number of affected rows in a query.
*

Zeile 519Zeile 524
		if(!$query)
{
$query = $this->db->last_query;

		if(!$query)
{
$query = $this->db->last_query;

		}

		}


return $this->db->num_fields($query);
}


return $this->db->num_fields($query);
}

Zeile 546Zeile 551
		while($table = $this->fetch_array($query))
{
$tables[] = $table['tbl_name'];

		while($table = $this->fetch_array($query))
{
$tables[] = $table['tbl_name'];

		}
$query->closeCursor();

		}
$query->closeCursor();

		return $tables;
}


		return $tables;
}


Zeile 561Zeile 566
	{
$query = $this->query("SELECT COUNT(name) as count FROM sqlite_master WHERE type='table' AND name='{$this->table_prefix}{$table}'");
$exists = $this->fetch_field($query, "count");

	{
$query = $this->query("SELECT COUNT(name) as count FROM sqlite_master WHERE type='table' AND name='{$this->table_prefix}{$table}'");
$exists = $this->fetch_field($query, "count");

		$query->closeCursor();


		$query->closeCursor();


		if($exists > 0)

		if($exists > 0)

		{

		{

			return true;

			return true;

		}

		}

		else
{
return false;

		else
{
return false;

Zeile 575Zeile 580

/**
* Check if a field exists in a database.


/**
* Check if a field exists in a database.

	 *

	 *

	 * @param string $field The field name.
* @param string $table The table name.
* @return boolean True when exists, false if not.

	 * @param string $field The field name.
* @param string $table The table name.
* @return boolean True when exists, false if not.

Zeile 603Zeile 608
		else
{
return false;

		else
{
return false;

		}

		}

	}

/**

	}

/**

Zeile 632Zeile 637
	 * @param string $fields Comma delimetered list of fields to be selected.
* @param string $conditions SQL formatted list of conditions to be matched.
* @param array $options List of options: group by, order by, order direction, limit, limit start.

	 * @param string $fields Comma delimetered list of fields to be selected.
* @param string $conditions SQL formatted list of conditions to be matched.
* @param array $options List of options: group by, order by, order direction, limit, limit start.

	 * @return PDOStatement The query data.
*/

	 * @return PDOStatement The query data.
*/

	function simple_select($table, $fields="*", $conditions="", $options=array())
{
$query = "SELECT ".$fields." FROM ".$this->table_prefix.$table;

	function simple_select($table, $fields="*", $conditions="", $options=array())
{
$query = "SELECT ".$fields." FROM ".$this->table_prefix.$table;

Zeile 661Zeile 666
		if(isset($options['limit_start']) && isset($options['limit']))
{
$query .= " LIMIT ".$options['limit_start'].", ".$options['limit'];

		if(isset($options['limit_start']) && isset($options['limit']))
{
$query .= " LIMIT ".$options['limit_start'].", ".$options['limit'];

		}
else if(isset($options['limit']))

		}
else if(isset($options['limit']))

		{
$query .= " LIMIT ".$options['limit'];
}

		{
$query .= " LIMIT ".$options['limit'];
}





		return $this->query($query);
}


		return $this->query($query);
}


Zeile 676Zeile 681
	 * @param string $table The table name to perform the query on.
* @param array $array An array of fields and their values.
* @return int|bool The insert ID if available or false if an error is found

	 * @param string $table The table name to perform the query on.
* @param array $array An array of fields and their values.
* @return int|bool The insert ID if available or false if an error is found

	 */

	 */

	function insert_query($table, $array)
{
global $mybb;

	function insert_query($table, $array)
{
global $mybb;

Zeile 746Zeile 751
					}

$values[$field] = $value;

					}

$values[$field] = $value;

				}

				}

				else
{
$values[$field] = $this->quote_val($value);

				else
{
$values[$field] = $this->quote_val($value);

Zeile 761Zeile 766
			INTO {$this->table_prefix}{$table} ({$fields})
VALUES {$insert_rows}
");

			INTO {$this->table_prefix}{$table} ({$fields})
VALUES {$insert_rows}
");

		$query->closeCursor();

		$query->closeCursor();

	}

/**

	}

/**

Zeile 775Zeile 780
	 * @return PDOStatement The query data.
*/
function update_query($table, $array, $where="", $limit="", $no_quote=false)

	 * @return PDOStatement The query data.
*/
function update_query($table, $array, $where="", $limit="", $no_quote=false)

	{

	{

		global $mybb;

if(!is_array($array))

		global $mybb;

if(!is_array($array))

Zeile 831Zeile 836
	private function quote_val($value, $quote="'")
{
if(is_int($value))

	private function quote_val($value, $quote="'")
{
if(is_int($value))

		{

		{

			$quoted = $value;
}
else

			$quoted = $value;
}
else

Zeile 859Zeile 864
		}

$query = $this->query("DELETE FROM {$this->table_prefix}$table $query");

		}

$query = $this->query("DELETE FROM {$this->table_prefix}$table $query");

		$query->closeCursor();

		$query->closeCursor();

		return $query;

		return $query;

	}


	}


	/**
* Escape a string
*

	/**
* Escape a string
*

Zeile 873Zeile 878
	{
$string = $this->db->escape_string($string);
return $string;

	{
$string = $this->db->escape_string($string);
return $string;

	}


	}


	/**
* Serves no purposes except compatibility
*

	/**
* Serves no purposes except compatibility
*

Zeile 888Zeile 893

/**
* Escape a string used within a like command.


/**
* Escape a string used within a like command.

	 *

	 *

	 * @param string $string The string to be escaped.
* @return string The escaped string.
*/

	 * @param string $string The string to be escaped.
* @return string The escaped string.
*/

Zeile 920Zeile 925
	 */
function optimize_table($table)
{

	 */
function optimize_table($table)
{

		$query = $this->query("VACUUM ".$this->table_prefix.$table."");
$query->closeCursor();

		// SQLite doesn't support table level optimization.
// Using `VACUUM [main | $db_name]` may also be blocked by any opened query cursor, hence generating an error.

	}

/**

	}

/**

Zeile 963Zeile 968
	 */
function show_fields_from($table)
{

	 */
function show_fields_from($table)
{

		$old_tbl_prefix = $this->table_prefix;
$this->set_table_prefix("");
$query = $this->simple_select("sqlite_master", "sql", "type = 'table' AND name = '{$old_tbl_prefix}{$table}'");
$this->set_table_prefix($old_tbl_prefix);
$table = trim(preg_replace('#CREATE\s+TABLE\s+"?'.$this->table_prefix.$table.'"?#i', '', $this->fetch_field($query, "sql")));
$query->closeCursor();

preg_match('#\((.*)\)#s', $table, $matches);


		$query = $this->write_query("PRAGMA TABLE_INFO('".$this->table_prefix.$table."')");









		$field_info = array();

		$field_info = array();

		$table_cols = explode(',', trim($matches[1]));
foreach($table_cols as $declaration)

		while($field = $this->fetch_array($query))


		{

		{

			$entities = preg_split('#\s+#', trim($declaration));
$column_name = preg_replace('/"?([^"]+)"?/', '\1', $entities[0]);












			if(!empty($field['pk']))
{
$field['_key'] = 'PRI';
$field['_extra'] = 'auto_increment';
}
else
{
$field['_key'] = '';
$field['_extra'] = '';
}

// SQLite allows NULLs in most PRIMARY KEY columns due to a bug in early versions, even in an INTEGER PRIMARY KEY column, read https://sqlite.org/lang_createtable.html for details. We won't fix this for consistency among other database engines.
$field['_nullable'] = $field['notnull'] ? 'NO' : 'YES';





			$field_info[] = array('Extra' => $entities[1], 'Field' => $column_name);








			$field_info[] = array(
'Field' => $field['name'],
'Type' => $field['type'],
'Null' => $field['_nullable'],
'Key' => $field['_key'],
'Default' => $field['dflt_value'],
'Extra' => $field['_extra'],
);

		}

		}



		$query->closeCursor();

		return $field_info;
}


		return $field_info;
}


Zeile 1075Zeile 1089
			$table_prefix = $this->table_prefix;
}


			$table_prefix = $this->table_prefix;
}


 
		$table_prefix_bak = $this->table_prefix;
$this->table_prefix = '';

		if($hard == false)
{

		if($hard == false)
{

			if($this->table_exists($table))

			if($this->table_exists($table_prefix.$table))

			{
$query = $this->query('DROP TABLE '.$table_prefix.$table);
}

			{
$query = $this->query('DROP TABLE '.$table_prefix.$table);
}

Zeile 1086Zeile 1102
		{
$query = $this->query('DROP TABLE '.$table_prefix.$table);
}

		{
$query = $this->query('DROP TABLE '.$table_prefix.$table);
}

 
		$this->table_prefix = $table_prefix_bak;


if(isset($query))
{


if(isset($query))
{