Mysqli Update Operation


Update existing records in a table using associative array. Instead of writing long update queries, you needs to pass associative array of keys(columns) and values(update values) and associative array of conditions with keys as columns and value as column value.This function will automatically create query for you and updates data.

You need to set $parameter_types as data type of columns before using this function. For examples if you have five columns then you need to pass data type of each column like "sssis" where s denotes the string data type, i denotes numeric data type.

Function Reference :
	              void dbUpdate(string $table_name, assoc. array $update_array [, assoc. array $update_condition_array=array()])) 


Name Type Required Parameter Info Example
table_name string Yes The name of the table to update old records any table name like employee_table,user_table
update_array array Yes Associative array with key as column name and values as column value. array("username"=>"abcd","gender"=>"male")
update_condition_array array Optional Associative array with key as column name and values as column value pass where condition to update old row. array("userid"=>15,"username"=>"abcd")


 $sdb= new SimplifiedDB(); 


Old row will be updated in table.


Debug Operation Result/Output
$sdb->query UPDATE user_roles SET `role_name`=?,`role_description`=? WHERE `roleid`=?
$sdb->rows_affected 1
$sdb->message_info Connected to database

More Examples

             $updateRoles["role_description"]="Manages system";