Vergleich inc/db_sqlite2.php - 1.4.2 - 1.4.4

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 6Zeile 6
 * Website: http://www.mybboard.com
* License: http://www.mybboard.com/license.php
*

 * Website: http://www.mybboard.com
* License: http://www.mybboard.com/license.php
*

 * $Id: db_sqlite2.php 4067 2008-08-04 03:59:08Z Tikitiki $

 * $Id: db_sqlite2.php 4279 2008-11-26 00:01:25Z Tikitiki $

 */


 */


class DB_SQLite

class DB_SQLite2

{
/**
* The title of this layer.

{
/**
* The title of this layer.

Zeile 147Zeile 147

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



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


		sqlite_query('PRAGMA short_column_names = 1', $this->link);

		@sqlite_query('PRAGMA short_column_names = 1', $this->link);

		return $this->link;
}


		return $this->link;
}


Zeile 175Zeile 175
			else
{
$alterdefs = preg_replace("#\sAFTER\s([a-z_]+?)(;*?)$#i", "", $alterdefs);

			else
{
$alterdefs = preg_replace("#\sAFTER\s([a-z_]+?)(;*?)$#i", "", $alterdefs);

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


				$alterdefs = preg_replace("#;$#i", "", $alterdefs);
$query = $this->alter_table_parse($tablename, $alterdefs, $string);

			}
}
else
{

			}
}
else
{

			$query = sqlite_query($this->link, $string, SQLITE_BOTH, $this->error_msg);








			if(version_compare(phpversion(), "5.1.0", ">="))
{
$query = sqlite_query($this->link, $string, SQLITE_BOTH, $this->error_msg);
}
else
{
$query = sqlite_query($this->link, $string, SQLITE_BOTH);
}

		}

if($this->error_msg && !$hide_errors)

		}

if($this->error_msg && !$hide_errors)

		{

		{

			$this->error($string, $this->error_msg, 1);

			$this->error($string, $this->error_msg, 1);

			exit;

			exit;

		}

if($query === false && !$hide_errors)
{
$this->error($string);
exit;

		}

if($query === false && !$hide_errors)
{
$this->error($string);
exit;

		}


		}


		$query_time = $this->get_execution_time();
$this->query_time += $query_time;
$this->query_count++;

		$query_time = $this->get_execution_time();
$this->query_time += $query_time;
$this->query_count++;

Zeile 231Zeile 239
			$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;\">".$string."</span></td>\n".
"</tr>\n".

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

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

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

Zeile 287Zeile 295
		if($row !== false)
{
$this->data_seek($query, $row);

		if($row !== false)
{
$this->data_seek($query, $row);

		}

		}

		$array = $this->fetch_array($query);
return $array[$field];
}

		$array = $this->fetch_array($query);
return $array[$field];
}

Zeile 500Zeile 508
		if($exists > 0)
{
return true;

		if($exists > 0)
{
return true;

		}
else

		}
else

		{
return false;
}

		{
return false;
}

Zeile 715Zeile 723
		if($this->version)
{
return $this->version;

		if($this->version)
{
return $this->version;

		}

		}

		$this->version = sqlite_libversion();

return $this->version;

		$this->version = sqlite_libversion();

return $this->version;

Zeile 729Zeile 737
	function optimize_table($table)
{
$this->query("VACUUM ".$this->table_prefix.$table."");

	function optimize_table($table)
{
$this->query("VACUUM ".$this->table_prefix.$table."");

	}

	}

	
/**
* Analyzes a specific table.

	
/**
* Analyzes a specific table.

Zeile 743Zeile 751

/**
* Show the "create table" command for a specific table.


/**
* Show the "create table" command for a specific table.

	 *

	 *

	 * @param string The name of the table.
* @return string The MySQL command to create the specified table.
*/
function show_create_table($table)

	 * @param string The name of the table.
* @return string The MySQL 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 = '{$this->table_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 = '{$this->table_prefix}{$table}' ORDER BY type DESC, name");
$this->set_table_prefix($old_tbl_prefix);


Zeile 770Zeile 778
		$query = $this->simple_select("sqlite_master", "sql", "type = 'table' AND name = '{$this->table_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 = $this->simple_select("sqlite_master", "sql", "type = 'table' AND name = '{$this->table_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")));



		

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

$field_info = array();

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

$field_info = array();

Zeile 934Zeile 942
	 * Perform an "Alter Table" query in SQLite < 3.2.0 - Code taken from http://code.jenseng.com/db/
*
* @param string The table (optional)

	 * Perform an "Alter Table" query in SQLite < 3.2.0 - Code taken from http://code.jenseng.com/db/
*
* @param string The table (optional)

 
	 * @param string The ADD/Change/Drop part of the query
* @param string The full part of the query

	 * @return integer the total size of all mysql tables or a specific table
*/

	 * @return integer the total size of all mysql tables or a specific table
*/

	function alter_table_parse($table, $alterdefs)

	function alter_table_parse($table, $alterdefs, $fullquery="")

	{

	{

 
		if(!$fullquery)
{
$fullquery = " ... {$alterdefs}";
}

if(!defined("TIME_NOW"))
{
define("TIME_NOW", time());
}


		if($alterdefs != '')
{
$result = $this->query("SELECT sql,name,type FROM sqlite_master WHERE tbl_name = '{$table}' ORDER BY type DESC");

		if($alterdefs != '')
{
$result = $this->query("SELECT sql,name,type FROM sqlite_master WHERE tbl_name = '{$table}' ORDER BY type DESC");

Zeile 986Zeile 1006
							if(sizeof($defparts) <= 2)
{
$this->error($alterdefs, 'near "'.$defparts[0].($defparts[1] ? ' '.$defparts[1] : '').'": syntax error');

							if(sizeof($defparts) <= 2)
{
$this->error($alterdefs, 'near "'.$defparts[0].($defparts[1] ? ' '.$defparts[1] : '').'": syntax error');

								return false;
}


								return false;
}


							$createtesttableSQL = substr($createtesttableSQL, 0, strlen($createtesttableSQL)-1).',';

							$createtesttableSQL = substr($createtesttableSQL, 0, strlen($createtesttableSQL)-1).',';

 
							
if(strstr($createtesttableSQL, $defparts[1]) !== false)
{
$this->error($fullquery, 'syntax error: '.$defparts[1].' column already exists in '.$table.' table');
}

							
for($i = 1; $i < sizeof($defparts); $i++)
{

							
for($i = 1; $i < sizeof($defparts); $i++)
{

Zeile 1008Zeile 1033
							{
if($newcols[$defparts[1]] != $defparts[1])
{

							{
if($newcols[$defparts[1]] != $defparts[1])
{

									$this->error($alterdefs, 'unknown column "'.$defparts[1].'" in "'.$table.'"');

									$this->error($fullquery, 'unknown column "'.$defparts[1].'" in "'.$table.'"');

									return false;
}


									return false;
}


Zeile 1032Zeile 1057
							}
else
{

							}
else
{

								$this->error($alterdefs, 'unknown column "'.$defparts[1].'" in "'.$table.'"', E_USER_WARNING);

								$this->error($fullquery, 'unknown column "'.$defparts[1].'" in "'.$table.'"', E_USER_WARNING);

								return false;
}
break;
case 'drop':
if(sizeof($defparts) < 2)
{

								return false;
}
break;
case 'drop':
if(sizeof($defparts) < 2)
{

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

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

								return false;
}


								return false;
}


Zeile 1060Zeile 1085
							}
else
{

							}
else
{

								$this->error($alterdefs, 'unknown column "'.$defparts[1].'" in "'.$table.'"');

								$this->error($fullquery, 'unknown column "'.$defparts[1].'" in "'.$table.'"');

								return false;
}
break;
default:

								return false;
}
break;
default:

							$this->error($alterdefs, 'near "'.$prevword.'": syntax error');

							$this->error($fullquery, 'near "'.$prevword.'": syntax error');

							return false;
}


							return false;
}