Updates all records which matches the $where statement in the given $table with the given $data via prepared statements.

@param string $table Table to update
@param array $data New data
@param string $where Where statement
@return int
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();
    }
1115659
public function updateRows(string $table, array $set, array $where): int
    {
        $update = new Update($this->options);
        $sqlParams = $update->buildQuery($table, $set, $where);
        return $this->query($sqlParams->getSql(), $sqlParams->getParams())->getAffected();
    }
794740
public function update($table, $data, $options = array())
    {
        // empty data
        if (empty($data))
            Throw new \ErrorException("SQL Error: Can't update empty data.");

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

        // build query string...
        $query_string = 'UPDATE `' . $this->pref . $table . '` SET ' . implode(',', $list) . $this->opt($options);

        try {
            return $this->doQuery($query_string); // ... and execute
        } catch (\Exception $e) {
            print_r($e->getMessage());
            return null;
        }
    }
196375
public static function c($table, $where) {
        $row = DB::qbr($table, array("where" => $where, "cols" => "id"));
        if (!$row) return false;
        return $row["id"];
    }
1185459
public static function delete($table, $where) {
        $delete = Delete::table($table);
        if (is_array($where)) {
            foreach ($where as $field => $value) {
                $delete->where($field, $value);
            }
        } else {
            $delete->where("id", $where);
        }
        return $delete->excuse();
    }
1215141
public static function update($table, $data, $condition, $option = false)
    {
        $db = self::Using(self::$using_dbo_id);
        return $db->update($table, $data, $condition, $option);
    }
1276259
public function delete($table, $where)
    {
        $context = $this->getCommandContext();
        $context->table    = $table;
        $context->data    = null;
        $context->where    = $where;
        $context->operation    = AnDatabase::OPERATION_DELETE;

        //Excute the delete operation
        if ($this->getCommandChain()->run('before.delete', $context) !== false) {
            //Create query statement
            $context->query = 'DELETE FROM '.$this->quoteName($this->getTableNeedle().$context->table)
                  .' '.$context->where
            ;

            //Execute the query
            $context->result = $this->execute($context->query);

            $context->affected = $this->_affected_rows;
            $this->getCommandChain()->run('after.delete', $context);
        }

        return $context->affected;
    }
715713
public function insert_or_update( $table, $data, $where ) {
		if ( ! isset( $this->table_defines[ $table ] ) ) {
			return false;
		}

		if ( $this->is_logical( $this->table_defines[ $table ] ) ) {
			$where['deleted_at'] = null;
		}

		$row = $this->select_row( $table, $where, 'id' );
		if ( empty( $row ) ) {
			$this->insert( $table, $data );
			if ( $this->get_last_error() ) {
				return false;
			}

			return $this->get_insert_id();
		}
		$where = [ 'id' => $row['id'] ];
		$this->update( $table, $data, $where );
		if ( $this->get_last_error() ) {
			return false;
		}

		return $row['id'];
	}
1178724
public function delete($where, $table = null)
    {
        $table = ($table) ?: $this->getTable();
        $sql = $this->getSql();
        $delete = $sql->delete($table);

        $delete->where($where);

        $statement = $sql->prepareStatementForSqlObject($delete);
        $result = $statement->execute();

        return $result->getAffectedRows();
    }
1126545
public function buildUpdateSQL($table = null, $data = array())
	{
		$sql = 'update ' . $this->parseTable($table) . ' set ';
		if(is_string($data))
		{
			$sql .= $data . ' ';
		}
		else
		{
			$data = $this->parseParams($data);
			foreach($data as $key => $value)
			{
				$sql .= $this->parseKeyword($key) . '=:' . $this->parseParamName($key) . ',';
			}
		}
		$where = $this->parseCondition(isset($this->operationOption['where']) ? $this->operationOption['where'] : '');
		if ('' !== $where)
		{
			$where = 'where ' . $where . ' ';
		}
		return substr($sql,0,-1) . ' '
				. $where
				. $this->parseOrder()
				. $this->parseLimit()
				. $this->parseLock()
				;
	}
166757
public function update($table, array $data, $conditions)
    {
        $nameFields = array_keys($data);
        $preparedValues = $this->prepareValues($data);
        $queryString = "UPDATE {$table} SET ";

        $fNumber = 0;
        foreach ($preparedValues as $key => $value) {
            unset($value);
            $queryString .= "{$nameFields[$fNumber]} = {$key}, ";
            $fNumber++;
        }

        $queryString = preg_replace('/,\ $/', ' ', $queryString);
        $queryString .= "WHERE {$conditions};";

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

        return $this->getAffectedRows();
    }
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();
    }
172534
public function set($data=null, $where=null)
    {
        if ($data)  {
            $this->getQuery()->set('data', $data);
        }
        if ($where) {
            $this->where($where);
        }
        
        return $this;
    }
69678
public function sqlUpdate(
		$table,
		array $properties,
		$where,
		array $where_params = [],
		$limit = null
	) {
		$attributes = [];
		foreach ($properties as $attribute => $value) {
			$attributes[] = $attribute . ' = :U' . $attribute; // name parameters after attribute
			if (array_key_exists(':U' . $attribute, $where_params)) {
				throw new Exception('Named parameter already defined: ' . $attribute);
			}
			$where_params[':U' . $attribute] = $value;
		}
		$sql = $this->queryBuilder->buildUpdate($table, $attributes, $where, $limit);
		$query = $this->database->prepare($sql);
		$query->execute($where_params);
		$this->addQuery($query->queryString, $where_params);
		return $query->rowCount();
	}
706297
public static function updateBatch($data, $where = null): IResult
    {
        $class = static::__getRealClassName();
        if(Update::hasUpdateRelation($class))
        {
            $query = Db::query()->table(ModelManager::getTable($class));
            $query = static::parseWhere($query, $where);

            $list = $query->select()->getArray();
            
            foreach($list as $row)
            {
                $model = static::newInstance($row);
                $model->set($data);
                $model->update();
            }
        }
        else
        {
            $query = static::query();
            $query = static::parseWhere($query, $where);

            $updateData = static::parseSaveData($data);

            // 更新前
            Event::trigger(static::__getRealClassName() . ':' . ModelEvents::BEFORE_BATCH_UPDATE, [
                'data'  => $updateData,
                'query' => $query,
            ], null, \Imi\Model\Event\Param\BeforeBatchUpdateEventParam::class);
            
            $result = $query->update($updateData);
    
            // 更新后
            Event::trigger(static::__getRealClassName() . ':' . ModelEvents::AFTER_BATCH_UPDATE, [
                'data'  => $updateData,
                'result'=> $result,
            ], null, \Imi\Model\Event\Param\BeforeBatchUpdateEventParam::class);
    
            return $result;
        }
    }
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);
    }
889601
public function GetDelete($Table, $Where, &$Data) {
      if (is_array($Data)) {
         // Grab the records.
         $Result = $this->SQL->GetWhere($Table, $Where)->ResultArray();
         
         if (empty($Result))
            return;
         
         // Put the records in the result array.
         if (isset($Data[$Table])) {
            $Data[$Table] = array_merge($Data[$Table], $Result);
         } else {
            $Data[$Table] = $Result;
         }
      }
      
      $this->SQL->Delete($Table, $Where);
   }