Vergleich inc/db_sqlite3.php - 1.4.4 - 1.4.16

  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_sqlite3.php 4224 2008-10-05 11:17:04Z Tikitiki $

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

 */

class DB_SQLite3

 */

class DB_SQLite3

Zeile 616Zeile 616
			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 626Zeile 654
	 * @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 654Zeile 682
	 *
* @param string The table name to perform the query on.
* @param array An array of fields and their values.

	 *
* @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 resource The query data.
*/
function update_query($table, $array, $where="", $limit="")


































	 * @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="")
{
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 = "";

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

Zeile 679Zeile 740
			$query .= " WHERE $where";
}


			$query .= " WHERE $where";
}


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

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

	}

/**

	}

/**

Zeile 731Zeile 792
	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 747Zeile 808
		$this->version = $this->db->get_attribute("ATTR_SERVER_VERSION");

return $this->version;

		$this->version = $this->db->get_attribute("ATTR_SERVER_VERSION");

return $this->version;

	}


	}


	/**
* Optimizes a specific table.
*

	/**
* Optimizes a specific table.
*

Zeile 757Zeile 818
	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 771Zeile 832

/**
* 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 795Zeile 856
	{
$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 845Zeile 906
	 * @return boolean True or false if supported or not.
*/
function supports_fulltext_boolean($table)

	 * @return boolean True or false if supported or not.
*/
function supports_fulltext_boolean($table)

	{
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.
*/
function create_fulltext_index($table, $column, $name="")

	 * @param string Name of the column to be indexed.
* @param string The index name, optional.
*/
function create_fulltext_index($table, $column, $name="")

	{
return false;
}

	{
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 867Zeile 928
	 * @param string The name of the table.
* @param string The name of the index.
*/

	 * @param string The name of the table.
* @param string The name of the index.
*/

	function drop_index($table, $name)












	function drop_index($table, $name)
{
$this->query("ALTER TABLE {$this->table_prefix}$table DROP INDEX $name");
}

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

	{

	{

		$this->query("ALTER TABLE {$this->table_prefix}$table DROP INDEX $name");

		return false;

	}

/**

	}

/**

Zeile 908Zeile 980
	 *
* @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 927Zeile 1001
			 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);
}
}

	}

/**

	}

/**