WIKINDX METHODS

Method:
update()

Class:
SQL

Method Call:
include_once("core/sql/SQL.php");
$db = new SQL();
$db->update(STRING: $table, ASSOC_ARRAY: $setArray, [STRING: $condition]);

Description:
Execute an UPDATE statement.

$setArray is an associative array field => value where field is a field within $table and value is the value you wish to set it to.

Do not add backticks, single-quotes etc. - the SQL class will do this automatically depending on the database we're connected to.

Usage:
For example (assuming the database object exists within a class as $this->db):

	$subTitle = "Beginner's Guide";
	$table = "WKX_resource";
	$setArray = array(
		"title"		=>	"WIKINDX",
		"subtitle"	=>	$subTitle,
		);
	$condition = "WHERE " . $this->db->formatField('id') . "=" . $this->db->tidyInput(666);
	$this->db->update($table, $setArray, $condition);
Note that, in this case, $subTitle is internally parsed by the tidyInput() method which will suitably escape the single quote in Beginner's Guide while backticks will be added to the fields title and subtitle. As always with a condition clause, you need to you will need to use formatField() and tidyInput() methods explicitly.

WIKINDX home      WIKINDX usage      WIKINDX classes