Vergleich inc/db_sqlite.php - 1.8.24 - 1.8.37

  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 75Zeile 80

/**
* The current version of SQLite.


/**
* The current version of SQLite.

	 *
* @var string

	 *
* @var string

	 */
public $version;


	 */
public $version;


Zeile 93Zeile 98
	 * @var string
*/
public $table_prefix;

	 * @var string
*/
public $table_prefix;


/**


/**

	 * The extension used to run the SQL database
*
* @var string

	 * The extension used to run the SQL database
*
* @var string

Zeile 103Zeile 108

/**
* Weather or not this engine can use the search functionality


/**
* Weather or not this engine can use the search functionality

	 *

	 *

	 * @var boolean
*/
public $can_search = true;

	 * @var boolean
*/
public $can_search = true;

Zeile 121Zeile 126
	 * @var float
*/
public $query_time = 0;

	 * @var float
*/
public $query_time = 0;


/**


/**

	 * Our pdo implementation
*
* @var dbpdoEngine

	 * Our pdo implementation
*
* @var dbpdoEngine

Zeile 141Zeile 146

require_once MYBB_ROOT."inc/db_pdo.php";



require_once MYBB_ROOT."inc/db_pdo.php";


		$this->db = new dbpdoEngine("sqlite:{$config['database']}");







		try {
$this->db = new dbpdoEngine("sqlite:{$config['database']}");
} catch (Exception $ex) {
$this->error("[READ] Unable to open the SQLite database");

return false;
}


$query_time = get_execution_time();



$query_time = get_execution_time();


Zeile 290Zeile 301
	 *
* @param string $query The query SQL.
* @param boolean|int $hide_errors 1 if hide errors, 0 if not.

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

	 * @return PDOStatement The query data.
*/

	 * @return PDOStatement The query data.
*/

	function write_query($query, $hide_errors=0)
{
return $this->query($query, $hide_errors);

	function write_query($query, $hide_errors=0)
{
return $this->query($query, $hide_errors);

	}


	}


	/**
* Return a result array for a query.
*

	/**
* Return a result array for a query.
*

Zeile 325Zeile 336
			$this->data_seek($query, $row);
}
$array = $this->fetch_array($query);

			$this->data_seek($query, $row);
}
$array = $this->fetch_array($query);

		return $array[$field];





		if($array !== null && $array !== false)
{
return $array[$field];
}
return null;

	}

/**

	}

/**

Zeile 627Zeile 642
	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;





		if($conditions != "")
{
$query .= " WHERE ".$conditions;

		if($conditions != "")
{
$query .= " WHERE ".$conditions;

Zeile 851Zeile 866
		$query = $this->query("DELETE FROM {$this->table_prefix}$table $query");
$query->closeCursor();
return $query;

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

	}

/**

	}

/**

	 * Escape a string
*
* @param string $string The string to be escaped.

	 * Escape a string
*
* @param string $string The string to be escaped.

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

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

	}

/**

	}

/**

	 * Serves no purposes except compatibility
*
* @param PDOStatement $query

	 * Serves no purposes except compatibility
*
* @param PDOStatement $query

Zeile 893Zeile 908
	 * @return string Version of MySQL.
*/
function get_version()

	 * @return string Version of MySQL.
*/
function get_version()

	{

	{

		if($this->version)
{
return $this->version;
}
$this->version = $this->db->get_attribute("ATTR_SERVER_VERSION");

		if($this->version)
{
return $this->version;
}
$this->version = $this->db->get_attribute("ATTR_SERVER_VERSION");





		return $this->version;
}


		return $this->version;
}


Zeile 907Zeile 922
	 * Optimizes a specific table.
*
* @param string $table The name of the table to be optimized.

	 * Optimizes a specific table.
*
* @param string $table The name of the table to be optimized.

	 */

	 */

	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 922Zeile 937
	function analyze_table($table)
{
$query = $this->query("ANALYZE ".$this->table_prefix.$table."");

	function analyze_table($table)
{
$query = $this->query("ANALYZE ".$this->table_prefix.$table."");

		$query->closeCursor();

		$query->closeCursor();

	}

/**

	}

/**

Zeile 953Zeile 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 1065Zeile 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 1076Zeile 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))
{