SwatDB/SwatDB.php
public static function updateColumn(
        $db,
        $table,
        $field,
        $value,
        $id_field,
        $ids,
        $where = null
    ) {
        $ids = self::initArray($ids);

        if (count($ids) === 0) {
            return;
        }

        $field = new SwatDBField($field, 'integer');
        $id_field = new SwatDBField($id_field, 'integer');

        $sql = 'update %s set %s = %s where %s in (%s) %s';

        foreach ($ids as &$id) {
            $id = $db->quote($id, $id_field->type);
        }

        $id_list = implode(',', $ids);

        $where = $where === null ? '' : 'and ' . $where;

        $sql = sprintf(
            $sql,
            $table,
            $field->name,
            $db->quote($value, $field->type),
            $id_field->name,
            $id_list,
            $where
        );

        return self::exec($db, $sql);
    }
public static function updateColumn(
        $db,
        $table,
        $field,
        $value,
        $id_field,
        $ids,
        $where = null
    ) {
        $ids = self::initArray($ids);

        if (count($ids) === 0) {
            return;
        }

        $field = new SwatDBField($field, 'integer');
        $id_field = new SwatDBField($id_field, 'integer');

        $sql = 'update %s set %s = %s where %s in (%s) %s';

        foreach ($ids as &$id) {
            $id = $db->quote($id, $id_field->type);
        }

        $id_list = implode(',', $ids);

        $where = $where === null ? '' : 'and ' . $where;

        $sql = sprintf(
            $sql,
            $table,
            $field->name,
            $db->quote($value, $field->type),
            $id_field->name,
            $id_list,
            $where
        );

        return self::exec($db, $sql);
    }
public static function updateColumn ( $ db , $ table , $ field , $ value , $ id_field , $ ids , $ where = null ) { $ ids = self :: initArray ( $ ids ) ; if ( count ( $ ids ) === 0 ) { return ; } $ field = new SwatDBField ( $ field , 'integer' ) ; $ id_field = new SwatDBField ( $ id_field , 'integer' ) ; $ sql = 'update %s set %s = %s where %s in (%s) %s' ; foreach ( $ ids as & $ id ) { $ id = $ db -> quote ( $ id , $ id_field -> type ) ; } $ id_list = implode ( ',' , $ ids ) ; $ where = $ where === null ? '' : 'and ' . $ where ; $ sql = sprintf ( $ sql , $ table , $ field -> name , $ db -> quote ( $ value , $ field -> type ) , $ id_field -> name , $ id_list , $ where ) ; return self :: exec ( $ db , $ sql ) ; }
Update a column

Convenience method to update a single database field for one or more
rows. One convenient use of this method is for processing {@link
SwatAction}s
that change a single database field.

@param MDB2_Driver_Common $db The database connection.

@param string $table The database table to query.

@param string $field The name of the database field to update. 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 $value The value to store in database field $field. The
type should correspond to the type of $field.

@param string $id_field The name of the database field that contains the
the id. 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 array $ids An array of identifiers corresponding to the database
rows to be updated. The type of the individual identifiers should
correspond to the type of $id_field.

@param string $where An optional additional where clause.

@return integer the number of rows updated.

@throws SwatDBException
Update a column