Executes a UPDATE query

@param string $table The name of table
@param array $data An associative array containing column-value pairs
@param array $conditions The conditions to search records
@return int The number of affected rows
193288
public function update($table, array $data, array $conditions)
    {
        $table = $this->getTable($table);
        $set = $this->buildSqlObject($data, ', ');
        $where = $this->buildSqlObject($conditions, ' AND ');

        $query = "UPDATE $table SET $set WHERE $where";
        $params = array_merge(array_values($data), array_values($conditions));
        return $this->executeUpdate($query, $params);
    }
906414
public function insert($table, array $data)
    {
        // Prepare
        $columnPart = "";
        $valuePart = "";

        // Loop the data
        foreach ($data as $column => $value) {
            $columnPart .= "`$column`, ";
            $valuePart .= "?, ";
        }

        // Remove last commas
        $columnPart = substr($columnPart, 0, -2);
        $valuePart = substr($valuePart, 0, -2);

        $query = "INSERT INTO `$table` ($columnPart) VALUES ($valuePart)";


        // Prepare and bind
        $statement = $this->prepare($query);

        $idx = 0;
        foreach ($data as $key => $value) {
            $statement->bindValue(($idx+1), $value, Database::typeOfValue($value));
            $idx++;
        }

        // Execute and return the execute returning value.
        return $statement->execute();
    }
1090862
public function updateTable($table, ...$tables)
    {
        $instance = $this->updateQueryInstance();

        $instance->updateQuery()->table($table, ...$tables);

        return $instance;
    }
1273729
public function update($table, $values, $conditions, $params = array())
    {
        $updates = array();
        if (!is_array($values)) {
            $values = array($values);
        }
        foreach ($values as $k => $value) {
            if (is_integer($k)) {
                $updates[] = $value;
            } else {
                $updates[] = $this->db->quoteColumn($k) . ' = :__' . $k;
                $params[':__' . $k] = $value;
            }
        }

        $sql = "UPDATE " . $this->db->quoteTable($table) . ' SET ' . implode(', ', $updates);
        $conditions = $this->buildConditions($conditions);
        if ('' === $conditions) {
            throw new Exception('Update condition must not be empty');
        }

        $sql .= ' WHERE ' . $conditions;

        return $this->setSql($sql)->execute($params);
    }
45800
public function update($data, $where = [])
    {
        /*
         | Trigger Before Update events if
         | defined by user into model class
         |
         */
        $this->triggerEvent('beforeUpdate');

        if (!empty($where)) {
            $whereStr = $this->buildWherePlaceholderName($where);
        } else {
            list($where, $whereStr) = $this->buildWhereForUpdate();
        }

        $sql = $this->getUpdateQuery($data, strtoupper(__FUNCTION__)).$whereStr;

        try {
            $stmt = $this->resolveConnection()->prepare($sql);

            //Bind all values to query statement
            foreach ($data as $key => $val) {
                $stmt->bindValue(":$key", $val);
            }

            foreach ($where as $key => $value) {
                $stmt->bindValue(":$key", $value);
            }

            static::$queries[] = $stmt->queryString;
            $affectedRow = $stmt->execute();

            /*
             | Trigger after update events if defined
             | into model class
             |
             */
            $this->triggerEvent('afterUpdate');

            return $affectedRow;
        } catch (\PDOException  $exception) {
            throw new \Exception($exception->getMessage());
        }
    }
309596
public function insert($table, $data)
    {
        $query = $this->provider->buildInsertQuery($table, $data);

        return $this->provider->query($query, null);
    }
1163409
public function update($table, $data, $where)
     {
         ksort($data);

         $fielDetail = null;

         foreach ($data as $key => $values) {
             $fielDetail .= "`$key`=:$key,";
         }

         $fielDetail = trim($fielDetail, ',');
         $stmt = $this->conn->prepare("UPDATE $table SET $fielDetail WHERE $where ");
         foreach ($data as $key => $values) {
             $stmt->bindValue(":$key", $values);
         }

         return $stmt->execute();
     }
351649
public function insert($table, array $data)
    {
        $nameFields = join(',', array_keys($data));
        $preparedValues = $this->prepareValues($data);
        $keyValues = join(",", array_keys($preparedValues));
        $queryString = "INSERT INTO {$table} ({$nameFields}) VALUES ({$keyValues});";

        $this->query($queryString, $preparedValues);

        return $this->getInsertId();
    }
445935
public function insert($table, $data)
    {
        // empty data
        if (empty($data))
            Throw new \ErrorException("SQL Error: Can't insert empty data.");

        // prepare data
        $cols = ($values = array());
        foreach ($data as $column => $value) {
            $cols[] = '`' . $column . '`';
            $values[] = "'" . $this->escape($value) . "'";
        }

        // build query string...
        $query_string = 'INSERT INTO `' . $this->getPrefix() . $table . '` (' . implode(',', $cols) . ') VALUES (' . implode(',', $values) . ')';

        return $this->doQuery($query_string); // ... and execute
    }
1233341
public function inc($table, $data, $condition)
    {
        $collection = $this->db->selectCollection($table);
        $result = $collection->update(
            MongoQueryBuilder::where($condition),
            array('$inc' => self::filterData($data)),
            $this->getOptions());

        return ($result['ok'] == 1 && $result['n'] > 0);
    }
324848
public function updateRecords($table, array $data, $where)
    {
        $dbHandle = $this->getDatabaseConnection();
        list($updateSet, $prepareSet) = $this->prepareUpdateData($data);

        $query = 'UPDATE ' . $table . '
                  SET ' . implode(', ', $updateSet) . '
                  WHERE ' . $where;

        $statement = $dbHandle->prepare($query);
        $executeResult = $statement->execute($prepareSet);

        $statement = $this->checkQueryError($statement, $executeResult, $prepareSet);
        return $statement->rowCount();
    }
772264
public function update($table, array $data, array $conditions, $filter = true)
    {
        if ($filter) {
            $data = $this->filterValues($table, $data);
        }

        if (empty($data)) {
            return 0;
        }

        $farray = array();
        foreach (array_keys($data) as $key) {
            $farray[] = "$key=:$key";
        }

        $carray = array();
        foreach (array_keys($conditions) as $key) {
            $carray[] = "$key=:$key";
        }

        $fields = implode(',', $farray);
        $sql = "UPDATE $table SET $fields WHERE " . implode(' AND ', $carray);

        $stmt = $this->pdo->prepare($sql);

        foreach ($data as $key => $value) {
            $stmt->bindValue(":$key", $value);
        }

        foreach ($conditions as $key => $value) {
            $stmt->bindValue(":$key", $value);
        }

        $stmt->execute();
        $this->executed[] = $sql;
        return $stmt->rowCount();
    }
763931
public function replace($table, $data, $statements)
    {
        $columns = array_keys($data);
        $columnIdName = $columns[0];

        if (isset($statements[0][1]) && count($data) == count($statements)) {
            $id = $statements[0][1];
        } else {
            $id = array_shift($data);
        }

        $where = $columnIdName . ' = ' . $id;

        $result = $this->select(
            $columns,
            $table,
            $where,
            null,
            1,
            $statements
        );

        if ($this->rowCount($result)) {
            return $this->update($table, $data, $statements, $where);
        }

        return $this->insert($table, $data, $statements);
    }
892564
public function update(string $table, array $data, array $where)
    {
        $created_at = $this->db->get($table, 'created_at', $where);
        $data['updated_at']=time();
        return $this->db->update($table, $data, $where);
        $data=[
            'created_at'=>$created_at
        ];
        return $this->db->update($table, $data, $where);
    }
1292548
public function insert($table, $data) {
        if (!is_array($data)) {
            return false;
        }

        $fragment_sql = $this->prepareBinding($data, ', ');
        $bind_values = array_values($data);
        $query = 'INSERT `'. $table.'` SET ' . $fragment_sql;

        return $this->run($query, $bind_values);
    }
905161
public static function update($table,$where=[],$data)
    {
        if(empty($data)) throw new Exception("DB update data is null");
        
        $column='';
        $bind=[];
        $ends=count($data)-1;
        $n=0;
        foreach ($data as $key=>$value) {
            $column.="`{$key}`=:{$key}";
            $bind[$key]=$value;
            if($n!=$ends){
                $column.=',';
            }
            $n++;
        }
        if(empty($where)){
            $where='';
        }else{
            $w=new Where($where);
            $where=' WHERE '.$w->parseWhere();
            $bind=array_merge($bind,$w->parseBind());
        }
        $sql=sprintf('UPDATE `:%s` SET %s %s',$table,$column,$where);
        $bind=array_merge($bind,$bind);
        return self::execute($sql,$bind);
    }
949335
public function update(array $data, array $where = [])
    {
        // Prepare query
        $query = $this->genUpdate($data, $where);
        $statement = $this->getInstance()->prepare($query);

        // Bind field values
        foreach ($data as $key => $value) {
            $statement->bindValue(":field_$key", $value, $this->isPdoInt($value));
        }

        // Bind where values
        foreach ($where as $key => $value) {
            $statement->bindValue(":where_$key", $value, $this->isPdoInt($value));
        }

        // Execute operation
        $statement->execute();

        // Return count of affected rows
        return $statement->rowCount();
    }