public function updateRows($table, array $settings, $filters = null, $bind = true)
    {
        //build the query
        $query = $this->getUpdateQuery($table);

        //foreach settings
        foreach ($settings as $key => $value) {
            //if value is not a vulnerability
            if (is_null($value) || is_bool($value)) {
                //just add it to the query
                $query->set($key, $value);
                continue;
            }

            //if bind is true or is an array and we want to bind it
            if ($bind === true || (is_array($bind) && in_array($key, $bind))) {
                //bind the value
                $value = $this->bind($value);
            }

            //add it to the query
            $query->set($key, $value);
        }

        //array('post_id=%s AND post_title IN %s', 123, array('asd'));
        if (is_array($filters)) {
            //can be array of arrays
            if (is_array($filters[0])) {
                foreach ($filters as $i => $filter) {
                    if (is_array($filters)) {
                        $format = array_shift($filter);

                        //reindex filters
                        $filter = array_values($filter);

                        //bind filters
                        foreach ($filter as $i => $value) {
                            $filter[$i] = $this->bind($value);
                        }

                        //combine
                        $query->where(vsprintf($format, $filter));
                    }
                }
            } else {
                $format = array_shift($filters);

                //reindex filters
                $filters = array_values($filters);

                //bind filters
                foreach ($filters as $i => $value) {
                    $filters[$i] = $this->bind($value);
                }

                //combine
                $query->where(vsprintf($format, $filters));
            }
        } else {
            $query->where($filters);
        }

        //run the query
        $this->query($query, $this->getBinds());

        return $this;
    }
public function updateRows($table, array $settings, $filters = null, $bind = true)
    {
        //build the query
        $query = $this->getUpdateQuery($table);

        //foreach settings
        foreach ($settings as $key => $value) {
            //if value is not a vulnerability
            if (is_null($value) || is_bool($value)) {
                //just add it to the query
                $query->set($key, $value);
                continue;
            }

            //if bind is true or is an array and we want to bind it
            if ($bind === true || (is_array($bind) && in_array($key, $bind))) {
                //bind the value
                $value = $this->bind($value);
            }

            //add it to the query
            $query->set($key, $value);
        }

        //array('post_id=%s AND post_title IN %s', 123, array('asd'));
        if (is_array($filters)) {
            //can be array of arrays
            if (is_array($filters[0])) {
                foreach ($filters as $i => $filter) {
                    if (is_array($filters)) {
                        $format = array_shift($filter);

                        //reindex filters
                        $filter = array_values($filter);

                        //bind filters
                        foreach ($filter as $i => $value) {
                            $filter[$i] = $this->bind($value);
                        }

                        //combine
                        $query->where(vsprintf($format, $filter));
                    }
                }
            } else {
                $format = array_shift($filters);

                //reindex filters
                $filters = array_values($filters);

                //bind filters
                foreach ($filters as $i => $value) {
                    $filters[$i] = $this->bind($value);
                }

                //combine
                $query->where(vsprintf($format, $filters));
            }
        } else {
            $query->where($filters);
        }

        //run the query
        $this->query($query, $this->getBinds());

        return $this;
    }
public function updateRows ( $ table , array $ settings , $ filters = null , $ bind = true ) { //build the query $ query = $ this -> getUpdateQuery ( $ table ) ; //foreach settings foreach ( $ settings as $ key => $ value ) { //if value is not a vulnerability if ( is_null ( $ value ) || is_bool ( $ value ) ) { //just add it to the query $ query -> set ( $ key , $ value ) ; continue ; } //if bind is true or is an array and we want to bind it if ( $ bind === true || ( is_array ( $ bind ) && in_array ( $ key , $ bind ) ) ) { //bind the value $ value = $ this -> bind ( $ value ) ; } //add it to the query $ query -> set ( $ key , $ value ) ; } //array('post_id=%s AND post_title IN %s', 123, array('asd')); if ( is_array ( $ filters ) ) { //can be array of arrays if ( is_array ( $ filters [ 0 ] ) ) { foreach ( $ filters as $ i => $ filter ) { if ( is_array ( $ filters ) ) { $ format = array_shift ( $ filter ) ; //reindex filters $ filter = array_values ( $ filter ) ; //bind filters foreach ( $ filter as $ i => $ value ) { $ filter [ $ i ] = $ this -> bind ( $ value ) ; } //combine $ query -> where ( vsprintf ( $ format , $ filter ) ) ; } } } else { $ format = array_shift ( $ filters ) ; //reindex filters $ filters = array_values ( $ filters ) ; //bind filters foreach ( $ filters as $ i => $ value ) { $ filters [ $ i ] = $ this -> bind ( $ value ) ; } //combine $ query -> where ( vsprintf ( $ format , $ filters ) ) ; } } else { $ query -> where ( $ filters ) ; } //run the query $ this -> query ( $ query , $ this -> getBinds ( ) ) ; return $ this ; }
Updates rows that match a filter given the update settings

@param *string      $table   Table name
@param *array       $setting Key/value array matching table columns
@param array|string $filters Filters to test against
@param bool|array   $bind    Whether to compute with binded variables

@return AbstractSql
Updates rows that match a filter given the update settings