DATA Methods
Database functions
select(), fetch(), write(), update(), delete(), execute(), tables(), fields()Requests and temporary storage
request(), cookie(), session(), config(), store()Formatting data
encode(), decode(), json(), text(), date(), weekday(), month()Template data
content(), parents(), directory()
update()
The update function works almost like the write() function, however, the record will be updated or a new record appended if the record doesn't exist. This means that the WHERE statement is mandatory.
int update( string table, array set, string where )
Return
Number of updated records.
Parameter
Description
tableThe table name.
setArray containing data to be written to table.
whereSQL where statement without the SQL keyword WHERE.
Update records
$DATA->update("data_test", array("test_char" => "foo", "test_text" => "bar"), "test_int = 5")
RETURN: 2
Record doesn't exist, therefore append.
$DATA->update("data_test", array("test_char" => "foo", "test_text" => "bar"), "test_int = 6")
RETURN: 1