Vergleich inc/db_sqlite.php - 1.8.6 - 1.8.26

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 30Zeile 30
	 * @var string
*/
public $type;

	 * @var string
*/
public $type;

 

/**
* PDOStatement objects of performed queries.
*
* @var array
*/
public $query_objects = array();


/**
* A count of the number of queries.


/**
* A count of the number of queries.

Zeile 75Zeile 82

/**
* The current table type in use (myisam/innodb)


/**
* The current table type in use (myisam/innodb)

	 *

	 *

	 * @var string
*/
public $table_type = "myisam";

	 * @var string
*/
public $table_type = "myisam";

Zeile 119Zeile 126
	 * Our pdo implementation
*
* @var dbpdoEngine

	 * Our pdo implementation
*
* @var dbpdoEngine

	 */

	 */

	var $db;

/**

	var $db;

/**

Zeile 133Zeile 140
		get_execution_time();

require_once MYBB_ROOT."inc/db_pdo.php";

		get_execution_time();

require_once MYBB_ROOT."inc/db_pdo.php";





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

$query_time = get_execution_time();

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

$query_time = get_execution_time();

Zeile 141Zeile 148
		$this->query_time += $query_time;

$this->connections[] = "[WRITE] {$config['database']} (Connected in ".format_time_duration($query_time).")";

		$this->query_time += $query_time;

$this->connections[] = "[WRITE] {$config['database']} (Connected in ".format_time_duration($query_time).")";





		if($this->db)
{
$this->query('PRAGMA short_column_names = 1');

		if($this->db)
{
$this->query('PRAGMA short_column_names = 1');

Zeile 185Zeile 192
				{
$query = $this->db->query($string);
$query->closeCursor();

				{
$query = $this->db->query($string);
$query->closeCursor();

				}

				}

				else
{
$query = $this->alter_table_parse($tablename, $alterdefs, $string);

				else
{
$query = $this->alter_table_parse($tablename, $alterdefs, $string);

Zeile 206Zeile 213
				);

$this->error($error['message'], $error['code']);

				);

$this->error($error['message'], $error['code']);

			}

			}

		}

		}

 

$this->query_objects[] = $query;


if($this->error_number($query) > 0 && !$hide_errors)
{


if($this->error_number($query) > 0 && !$hide_errors)
{

Zeile 220Zeile 229
		$this->query_count++;

if($mybb->debug_mode)

		$this->query_count++;

if($mybb->debug_mode)

		{

		{

			$this->explain_query($string, $query_time);
}


			$this->explain_query($string, $query_time);
}


Zeile 228Zeile 237
		{
$query->closeCursor();
return null;

		{
$query->closeCursor();
return null;

		}

		}


return $query;
}


return $query;
}

Zeile 246Zeile 255
			$this->explain .= "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n".
"<tr>\n".
"<td colspan=\"8\" style=\"background-color: #ccc;\"><strong>#".$this->query_count." - Select Query</strong></td>\n".

			$this->explain .= "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n".
"<tr>\n".
"<td colspan=\"8\" style=\"background-color: #ccc;\"><strong>#".$this->query_count." - Select Query</strong></td>\n".

				"</tr>\n".
"<tr>\n".
"<td colspan=\"8\" style=\"background-color: #fefefe;\"><span style=\"font-family: Courier; font-size: 14px;\">".htmlspecialchars_uni($string)."</span></td>\n".
"</tr>\n".
"<tr>\n".

				"</tr>\n".
"<tr>\n".
"<td colspan=\"8\" style=\"background-color: #fefefe;\"><span style=\"font-family: Courier; font-size: 14px;\">".htmlspecialchars_uni($string)."</span></td>\n".
"</tr>\n".
"<tr>\n".

				"<td colspan=\"8\" style=\"background-color: #fff;\">Query Time: ".format_time_duration($qtime)."</td>\n".
"</tr>\n".
"</table>\n".

				"<td colspan=\"8\" style=\"background-color: #fff;\">Query Time: ".format_time_duration($qtime)."</td>\n".
"</tr>\n".
"</table>\n".

Zeile 294Zeile 303
	 * @param PDOStatement $query The result data.
* @param int $resulttype One of PDO's constants: FETCH_ASSOC, FETCH_BOUND, FETCH_CLASS, FETCH_INTO, FETCH_LAZY, FETCH_NAMED, FETCH_NUM, FETCH_OBJ or FETCH_BOTH
* @return array The array of results.

	 * @param PDOStatement $query The result data.
* @param int $resulttype One of PDO's constants: FETCH_ASSOC, FETCH_BOUND, FETCH_CLASS, FETCH_INTO, FETCH_LAZY, FETCH_NAMED, FETCH_NUM, FETCH_OBJ or FETCH_BOTH
* @return array The array of results.

	 */

	 */

	function fetch_array($query, $resulttype=PDO::FETCH_BOTH)
{
$array = $this->db->fetch_array($query, $resulttype);

	function fetch_array($query, $resulttype=PDO::FETCH_BOTH)
{
$array = $this->db->fetch_array($query, $resulttype);

Zeile 328Zeile 337
	function data_seek($query, $row)
{
$this->db->seek($query, $row);

	function data_seek($query, $row)
{
$this->db->seek($query, $row);

 
	}

/**
* Closes cursors of registered queries.
*
*/
function close_cursors()
{
$result = true;

foreach($this->query_objects as $query)
{
if(!$query->closeCursor())
{
$result = false;
}
}

return $result;

	}

/**

	}

/**

Zeile 359Zeile 387
	function close()
{
return;

	function close()
{
return;

	}


	}


	/**
* Return an error number.
*

	/**
* Return an error number.
*

Zeile 381Zeile 409

/**
* Return an error string.


/**
* Return an error string.

	 *

	 *

	 * @param PDOStatement $query
* @return string The explanation for the current error.
*/

	 * @param PDOStatement $query
* @return string The explanation for the current error.
*/

Zeile 393Zeile 421
			{
$query = $this->db->last_query;
}

			{
$query = $this->db->last_query;
}





			$error_string = $this->db->error_string($query);
$this->error_number = "";

			$error_string = $this->db->error_string($query);
$this->error_number = "";





			return $error_string;
}

return '';

			return $error_string;
}

return '';

	}


	}


	/**
* Output a database error.
*

	/**
* Output a database error.
*

Zeile 416Zeile 444
		if($this->error_reporting)
{
if($query == null)

		if($this->error_reporting)
{
if($query == null)

			{

			{

				$query = $this->db->last_query;
}

if($error_no == 0)
{
$error_no = $this->error_number($query);

				$query = $this->db->last_query;
}

if($error_no == 0)
{
$error_no = $this->error_number($query);

			}

			}


if($error == "")
{


if($error == "")
{

Zeile 463Zeile 491
	function affected_rows($query=null)
{
if($query == null)

	function affected_rows($query=null)
{
if($query == null)

		{
$query = $this->db->last_query;
}

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

		{
$query = $this->db->last_query;
}

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


/**
* Return the number of fields.


/**
* Return the number of fields.

Zeile 488Zeile 516

/**
* Lists all tables in the database.


/**
* Lists all tables in the database.

	 *

	 *

	 * @param string $database The database name.
* @param string $prefix Prefix of the table (optional)
* @return array The table list.

	 * @param string $database The database name.
* @param string $prefix Prefix of the table (optional)
* @return array The table list.

Zeile 500Zeile 528
			$query = $this->query("SELECT tbl_name FROM sqlite_master WHERE type = 'table' AND tbl_name LIKE '".$this->escape_string($prefix)."%'");
}
else

			$query = $this->query("SELECT tbl_name FROM sqlite_master WHERE type = 'table' AND tbl_name LIKE '".$this->escape_string($prefix)."%'");
}
else

		{

		{

			$query = $this->query("SELECT tbl_name FROM sqlite_master WHERE type = 'table'");

			$query = $this->query("SELECT tbl_name FROM sqlite_master WHERE type = 'table'");

		}

		}


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


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

		}
$query->closeCursor();

		}
$query->closeCursor();

		return $tables;
}


		return $tables;
}


Zeile 553Zeile 581
			if($row['name'] == $field)
{
++$exists;

			if($row['name'] == $field)
{
++$exists;

			}
}


			}
}


		$query->closeCursor();

if($exists > 0)

		$query->closeCursor();

if($exists > 0)

Zeile 856Zeile 884
	 */
function escape_string_like($string)
{

	 */
function escape_string_like($string)
{

		return $this->escape_string(str_replace(array('%', '_') , array('\\%' , '\\_') , $string));

		return $this->escape_string(str_replace(array('\\', '%', '_') , array('\\\\', '\\%' , '\\_') , $string));

	}

/**

	}

/**

Zeile 904Zeile 932
	 * @return string The SQLite command to create the specified table.
*/
function show_create_table($table)

	 * @return string The SQLite command to create the specified table.
*/
function show_create_table($table)

	{
$old_tbl_prefix = $this->table_prefix;
$this->set_table_prefix("");

	{
$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}' ORDER BY type DESC, name");
$this->set_table_prefix($old_tbl_prefix);


		$query = $this->simple_select("sqlite_master", "sql", "type = 'table' AND name = '{$old_tbl_prefix}{$table}' ORDER BY type DESC, name");
$this->set_table_prefix($old_tbl_prefix);


Zeile 1084Zeile 1112
	 *
* @param string $table The table
* @param array $replacements The replacements

	 *
* @param string $table The table
* @param array $replacements The replacements

	 * @param mixed $default_field The default field(s)


	 * @param string|array $default_field The default field(s)
* @param boolean $insert_id Whether or not to return an insert id. True by default

	 * @return int|PDOStatement|bool Returns either the insert id (if a new row is inserted), the query resource (if a row is updated) or false on failure
*/

	 * @return int|PDOStatement|bool Returns either the insert id (if a new row is inserted), the query resource (if a row is updated) or false on failure
*/

	function replace_query($table, $replacements=array(), $default_field="")

	function replace_query($table, $replacements=array(), $default_field="", $insert_id=true)

	{
global $mybb;


	{
global $mybb;


Zeile 1257Zeile 1286
				{
$defparts = preg_split("/[\s]+/", $def, -1, PREG_SPLIT_NO_EMPTY);
$action = strtolower($defparts[0]);

				{
$defparts = preg_split("/[\s]+/", $def, -1, PREG_SPLIT_NO_EMPTY);
$action = strtolower($defparts[0]);





					switch($action)
{
case 'change':

					switch($action)
{
case 'change':

Zeile 1300Zeile 1329
							}
break;
case 'drop':

							}
break;
case 'drop':

							if(sizeof($defparts) < 2)
{

							if(sizeof($defparts) < 2)
{

								$this->error($fullquery, 'near "'.$defparts[0].($defparts[1] ? ' '.$defparts[1] : '').'": syntax error');
return false;
}

								$this->error($fullquery, 'near "'.$defparts[0].($defparts[1] ? ' '.$defparts[1] : '').'": syntax error');
return false;
}

Zeile 1344Zeile 1373
				if($query === false)
{
return false;

				if($query === false)
{
return false;

				}

				}

				$query->closeCursor();
// End block


				$query->closeCursor();
// End block


Zeile 1386Zeile 1415

/**
* Drops a column


/**
* Drops a column

	 *
* @param string $table The table
* @param string $column The column name

	 *
* @param string $table The table
* @param string $column The column name

	 * @return PDOStatement
*/
function drop_column($table, $column)

	 * @return PDOStatement
*/
function drop_column($table, $column)

Zeile 1409Zeile 1438
		$query = $this->write_query("ALTER TABLE {$this->table_prefix}{$table} ADD {$column} {$definition}");
$query->closeCursor();
return $query;

		$query = $this->write_query("ALTER TABLE {$this->table_prefix}{$table} ADD {$column} {$definition}");
$query->closeCursor();
return $query;

	}


	}


	/**
* Modifies a column

	/**
* Modifies a column

	 *

	 *

	 * @param string $table The table
* @param string $column The column name

	 * @param string $table The table
* @param string $column The column name

	 * @param string $new_definition the new column definition
*/
function modify_column($table, $column, $new_definition)
{




	 * @param string $new_definition the new column definition
* @param boolean|string $new_not_null Whether to "drop" or "set" the NOT NULL attribute (no change if false)
* @param boolean|string $new_default_value The new default value, or false to drop the attribute
* @return bool Returns true if all queries are executed successfully or false if one of them failed
*/
function modify_column($table, $column, $new_definition, $new_not_null=false, $new_default_value=false)
{

		// We use a rename query as both need to duplicate the table etc...

		// We use a rename query as both need to duplicate the table etc...

		$this->rename_column($table, $column, $column, $new_definition);

		return $this->rename_column($table, $column, $column, $new_definition, $new_not_null, $new_default_value);

	}

	}





	/**
* Renames a column
*

	/**
* Renames a column
*

Zeile 1431Zeile 1463
	 * @param string $old_column The old column name
* @param string $new_column the new column name
* @param string $new_definition the new column definition

	 * @param string $old_column The old column name
* @param string $new_column the new column name
* @param string $new_definition the new column definition

	 * @return PDOStatement



	 * @param boolean|string $new_not_null Whether to "drop" or "set" the NOT NULL attribute (no change if false)
* @param boolean|string $new_default_value The new default value, or false to drop the attribute
* @return bool Returns true if all queries are executed successfully

	 */

	 */

	function rename_column($table, $old_column, $new_column, $new_definition)

	function rename_column($table, $old_column, $new_column, $new_definition, $new_not_null=false, $new_default_value=false)

	{

	{

 
		if($new_not_null !== false)
{
if(strtolower($new_not_null) == "set")
{
$not_null = "NOT NULL";
}
else
{
$not_null = "NULL";
}
}
else
{
$not_null = '';
}

if($new_default_value !== false)
{
$default = "DEFAULT ".$new_default_value;
}
else
{
$default = '';
}


		// This will trigger the "alter_table_parse" function which will copy the table and rename the column

		// This will trigger the "alter_table_parse" function which will copy the table and rename the column

		return $this->write_query("ALTER TABLE {$this->table_prefix}{$table} CHANGE {$old_column} {$new_column} {$new_definition}");

		return (bool) $this->write_query("ALTER TABLE {$this->table_prefix}{$table} CHANGE {$old_column} {$new_column} {$new_definition} {$not_null} {$default}");

	}

/**

	}

/**