Please enable JavaScript to view this site.

Navigation: Advanced topics > Programming topics > Database API > Methods

Database API: Update

Scroll Prev Next More

 

Updates records in the database. The Update method overwrites existing records in the database instead of adding new ones.

 

Note: the third parameter must be specified for the method to be executed successfully.

Syntax

 

DB.Update(table, data, keyvalues);
// or
DB.Update(table, data, where);

Arguments

table

the table where you want to update the data.

data

an array of values that overwrites the existing record.

keyvalues

an array of key values that define the condition for the Update query.

where

the condition for the Update query.

Return value

No return value.

Example

 

// Update the record with id=50 in the 'Cars' table
 
dynamic data = XVar.Array();
dynamic keyvalues = XVar.Array();
data["make"]="Toyota";
data["model"]="RAV4";
data["price"]=16000;
keyvalues["id"]=50;
DB.Update("cars", data, keyvalues);

 

Alternative syntax:

 

// Update a record in the 'Cars' table where id=50
 
dynamic data = XVar.Array();
data["make"]="Toyota";
data["model"]="RAV4";
data["price"]=16000;
DB.Update("cars", data, "id=50");

See also:

Database API: Insert()

Database API: Delete()

Database API: Select()

About Database API