SwatDB/SwatDB.php
public static function updateRow(
        $db,
        $table,
        $fields,
        $values,
        $id_field,
        $id
    ) {
        self::initFields($fields);
        $id_field = new SwatDBField($id_field, 'integer');
        $sql = 'update %s set %s where %s = %s';
        $updates = array();

        foreach ($fields as &$field) {
            $value = isset($values[$field->name])
                ? $values[$field->name]
                : null;

            $updates[] = sprintf(
                '%s = %s',
                $field->name,
                $db->quote($value, $field->type)
            );
        }

        $update_list = implode(',', $updates);

        $sql = sprintf(
            $sql,
            $table,
            $update_list,
            $id_field->name,
            $db->quote($id, $id_field->type)
        );

        self::exec($db, $sql);
    }
public static function updateRow(
        $db,
        $table,
        $fields,
        $values,
        $id_field,
        $id
    ) {
        self::initFields($fields);
        $id_field = new SwatDBField($id_field, 'integer');
        $sql = 'update %s set %s where %s = %s';
        $updates = array();

        foreach ($fields as &$field) {
            $value = isset($values[$field->name])
                ? $values[$field->name]
                : null;

            $updates[] = sprintf(
                '%s = %s',
                $field->name,
                $db->quote($value, $field->type)
            );
        }

        $update_list = implode(',', $updates);

        $sql = sprintf(
            $sql,
            $table,
            $update_list,
            $id_field->name,
            $db->quote($id, $id_field->type)
        );

        self::exec($db, $sql);
    }
public static function updateRow ( $ db , $ table , $ fields , $ values , $ id_field , $ id ) { self :: initFields ( $ fields ) ; $ id_field = new SwatDBField ( $ id_field , 'integer' ) ; $ sql = 'update %s set %s where %s = %s' ; $ updates = array ( ) ; foreach ( $ fields as & $ field ) { $ value = isset ( $ values [ $ field -> name ] ) ? $ values [ $ field -> name ] : null ; $ updates [ ] = sprintf ( '%s = %s' , $ field -> name , $ db -> quote ( $ value , $ field -> type ) ) ; } $ update_list = implode ( ',' , $ updates ) ; $ sql = sprintf ( $ sql , $ table , $ update_list , $ id_field -> name , $ db -> quote ( $ id , $ id_field -> type ) ) ; self :: exec ( $ db , $ sql ) ; }
Update a row

Convenience method to update multiple fields of a single database row.
One convenient use of this method is for save data on an edit page.

@param MDB2_Driver_Common $db The database connection.

@param string $table The database table to update.

@param array $fields An array of fields to be updated. Can be
given in the form type:name where type is a standard MDB2
datatype. If type is ommitted, then text is assummed.

@param array $values An associative array of values to store in the
database.  The array keys should correspond to field names.
The type of the individual values should correspond to the
field type.

@param string $id_field The name of the database field that contains an
identifier of row to be updated. Can be given in the form
type:name where type is a standard MDB2 datatype. If type is
ommitted, then integer is assummed for this field.

@param mixed $id The value to look for in the $id_field column. The
type should correspond to the type of $field.

@throws SwatDBException
Update a row