Vergleich inc/db_sqlite2.php - 1.4.4 - 1.4.15

  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 4279 2008-11-26 00:01:25Z Tikitiki $

 * $Id: db_sqlite2.php 5379 2011-02-21 11:06:42Z Tomm $

 */

class DB_SQLite2

 */

class DB_SQLite2

Zeile 596Zeile 596
			VALUES ('".$values."')
");
return $this->insert_id();

			VALUES ('".$values."')
");
return $this->insert_id();

 
	}

/**
* Build an insert query from an array.
*
* @param string The table name to perform the query on.
* @param array An array of fields and their values.
* @return string The query string.
*/
function build_insert_query($table, $array)
{
$comma = $query1 = $query2 = "";
if(!is_array($array))
{
return false;
}
$comma = "";
$query1 = "";
$query2 = "";
foreach($array as $field => $value)
{
$query1 .= $comma.$field;
$query2 .= $comma."'".$value."'";
$comma = ", ";
}
return "INSERT
INTO ".TABLE_PREFIX.$table." (".$query1.")
VALUES (".$query2.")";

	}

/**

	}

/**

Zeile 606Zeile 634
	 * @return int The insert ID if available
*/
function insert_query_multiple($table, $array)

	 * @return int The insert ID if available
*/
function insert_query_multiple($table, $array)

	{
if(!is_array($array))
{

	{
if(!is_array($array))
{

			return false;
}
// Field names

			return false;
}
// Field names

Zeile 636Zeile 664
	 * @param array An array of fields and their values.
* @param string An optional where clause for the query.
* @param string An optional limit clause for the query.

	 * @param array An array of fields and their values.
* @param string An optional where clause for the query.
* @param string An optional limit clause for the query.

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


































	 * @return resource The query data.
*/
function update_query($table, $array, $where="", $limit="")
{
if(!is_array($array))
{
return false;
}

$comma = "";
$query = "";

foreach($array as $field => $value)
{
$query .= $comma.$field."='".$value."'";
$comma = ", ";
}

if(!empty($where))
{
$query .= " WHERE $where";
}

return $this->query("UPDATE {$this->table_prefix}$table SET $query");
}

/**
* Build an update query from an array.
*
* @param string The table name to perform the query on.
* @param array An array of fields and their values.
* @param string An optional where clause for the query.
* @param string An optional limit clause for the query.
* @return string The query string.
*/
function build_update_query($table, $array, $where="", $limit="")

	{
if(!is_array($array))
{
return false;

	{
if(!is_array($array))
{
return false;

		}

		}

		
$comma = "";
$query = "";

foreach($array as $field => $value)

		
$comma = "";
$query = "";

foreach($array as $field => $value)

		{

		{

			$query .= $comma.$field."='".$value."'";
$comma = ", ";

			$query .= $comma.$field."='".$value."'";
$comma = ", ";

		}

		}

		
if(!empty($where))
{
$query .= " WHERE $where";
}


		
if(!empty($where))
{
$query .= " WHERE $where";
}


		return $this->query("UPDATE {$this->table_prefix}$table SET $query");

		return "UPDATE {$this->table_prefix}{$table} SET {$query}";

	}

	}



	

	/**
* Build a delete query.
*

	/**
* Build a delete query.
*

Zeile 711Zeile 772
	function escape_string_like($string)
{
return $this->escape_string(str_replace(array('%', '_') , array('\\%' , '\\_') , $string));

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

	}

/**

	}

/**

	 * Gets the current version of SQLLite.
*
* @return string Version of MySQL.

	 * Gets the current version of SQLLite.
*
* @return string Version of MySQL.

Zeile 727Zeile 788
		$this->version = sqlite_libversion();

return $this->version;

		$this->version = sqlite_libversion();

return $this->version;

	}


	}


	/**
* Optimizes a specific table.
*

	/**
* Optimizes a specific table.
*

Zeile 737Zeile 798
	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 751Zeile 812

/**
* 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.
*/

	 * @param string The name of the table.
* @return string The MySQL command to create the specified table.
*/

Zeile 775Zeile 836
	{
$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}'");

		$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")));


		$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")));


Zeile 829Zeile 890
		return false;
}


		return false;
}


	/**

	/**

	 * Creates a fulltext index on the specified column in the specified table with optional index name.

	 * Creates a fulltext index on the specified column in the specified table with optional index name.

	 *
* @param string The name of the table.

	 *
* @param string The name of the table.

	 * @param string Name of the column to be indexed.
* @param string The index name, optional.

	 * @param string Name of the column to be indexed.
* @param string The index name, optional.

	 */

	 */

	function create_fulltext_index($table, $column, $name="")
{
return false;
}

	function create_fulltext_index($table, $column, $name="")
{
return false;
}














	
/**
* Checks to see if an index exists on a specified table
*
* @param string The name of the table.
* @param string The name of the index.
*/
function index_exists($table, $index)
{
return false;
}


	/**
* Drop an index with the specified name from the specified table
*

	/**
* Drop an index with the specified name from the specified table
*

Zeile 888Zeile 960
	 *
* @param string The table
* @param array The values

	 *
* @param string The table
* @param array The values

 
	 * @param string The default field
* @param boolean Whether or not to return an insert id. True by default

	 */

	 */

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

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

	{
$columns = '';
$values = '';

	{
$columns = '';
$values = '';

Zeile 907Zeile 981
			 return false;
}


			 return false;
}


		return $this->query("REPLACE INTO {$this->table_prefix}{$table} ({$columns}) VALUES({$values})");
















































































		if($default_field == "")
{
return $this->write_query("REPLACE INTO {$this->table_prefix}{$table} ({$columns}) VALUES({$values})");
}
else
{
$update = false;
$query = $this->write_query("SELECT {$default_field} FROM {$this->table_prefix}{$table}");

while($column = $this->fetch_array($query))
{
if($column[$default_field] == $replacements[$default_field])
{
$update = true;
break;
}
}

if($update === true)
{
return $this->update_query($table, $replacements, "{$default_field}='".$replacements[$default_field]."'");
}
else
{
return $this->insert_query($table, $replacements, $insert_id);
}
}
}

/**
* Replace contents of table with values
*
* @param string The table
* @param array The replacements
*/
function build_replace_query($table, $replacements=array(), $default_field="")
{
$columns = '';
$values = '';
$comma = '';
foreach($replacements as $column => $value)
{
$columns .= $comma.$column;
$values .= $comma."'".$value."'";

$comma = ',';
}

if(empty($columns) || empty($values))
{
return false;
}

if($default_field == "")
{
return "REPLACE INTO {$this->table_prefix}{$table} ({$columns}) VALUES({$values})";
}
else
{
$update = false;
$query = $this->write_query("SELECT {$default_field} FROM {$this->table_prefix}{$table}");

while($column = $this->fetch_array($query))
{
if($column[$default_field] == $replacements[$default_field])
{
$update = true;
break;
}
}

if($update === true)
{
return $this->build_update_query($table, $replacements, "{$default_field}='".$replacements[$default_field]."'");
}
else
{
return $this->build_insert_query($table, $replacements, $insert_id);
}
}

	}

/**

	}

/**