Build and Get SET statement

$this->getSetStmt(DB::INSERT, "mytable", array("name" => "John"));
will return:
INSERT INTO
@param string $syntax INSERT, UPDATE, REPLACE
@param string $table
@param array $data
@param null $where
@return \PDOStatement
508985
private function getSetStmt($syntax, $table, $data, $where = null)
    {
        $columns = array();

        foreach (array_keys($data) as $column) {
            $columns[] = "`" . $column . "` = ?";
        }
        $columns = implode(", ", $columns);

        $sql = "$syntax `$table` SET " . $columns . $this->buildWhere($where);

        return $this->prepare($sql);
    }
179043
public function get(string $table='', $limit=FALSE, $offset=FALSE): ?PDOStatement
	{
		// Set the table
		if ( ! empty($table))
		{
			$this->from($table);
		}

		// Set the limit, if it exists
		if (\is_int($limit))
		{
			$this->limit($limit, $offset);
		}

		return $this->_run('get', $table);
	}
575786
public function insert($tableName, array $data)
    {
        $query = sprintf("INSERT INTO $tableName (%s) VALUES (%s)",
            implode(', ', array_keys($data)), 
            implode(', ', array_fill(0, count($data), '?'))
        );

        $stmt = $this->prepare($query);
        $stmt->execute(array_values($data));
        return $stmt;
    }
1362437
public static function update($sqlstatement, array $data = [])
    {
        static::verifyConnection();

        if (preg_match("/^update\s[\w\d_`]+\s\bset\b\s.+\s\bwhere\b\s.+$/i", $sqlstatement)) {
            return static::executePrepareQuery($sqlstatement, $data);
        }

        return false;
    }
516700
public function update($table, $set, $where, $bind = array())
    {
        $sql = "UPDATE " . $table . " SET ";

        if(is_array($set)) {
            foreach($set as $field => $value) {
                $sql .= $field ." = ". $value . ",";
            }

            $sql = rtrim($sql,",");

        }else{
            $sql .= $set;
        }


        $sql .= " WHERE " . $where . ";";

        $bind = $this->cleanup($bind);

        return $this->run($sql, $bind);
    }
875211
public function update($table = '', $data = array())
    {
        if (empty($data)) {
            die('数据不能为空！');
        }

        $sql = 'UPDATE '.$table.' SET ';
        //字段名处理
        foreach ($data as $k => $v) {
            $sql = $sql.$k.'=:'.$k.',';

            $this->bindParam($k, $v);
        }
        $sql = rtrim($sql, ',');
        $sql = $sql.' WHERE id='.$data['id'];

        return $this->execute($sql);
    }
1006801
public function update($table, $data, $where = '')
    {
        $fieldDetails = null;
        foreach ($data as $key => $value) {
            $fieldDetails .= "$key = :$key,";
        }
        $fieldDetails = rtrim($fieldDetails, ',');
        $query = "UPDATE $table SET $fieldDetails ".($where ? 'WHERE '.$where : '');
        $this->prepare($query);

        foreach ($data as $key => $value) {
            $this->bind(":$key", $value);
        }
        try {
            $this->execute();

            return true;
        } catch (PDOException $e) {
            echo $e->errorInfo[2];

            return false;
        }
    }
1325111
public function update($table, $data = false)
    {
        if ($data == false) {
            $data = $table;
        } else {
            $this->table($table);
        }

        // Escape SQL 
        foreach ($data as $key => $value) {
            $data[$key] = $this->quote($value);
        }

        $this->queryCompiler->getQuery()->update($data);

        $this->queryCompiler->compile('update');

        return $this->getResult('get');
    }
807240
public static function update($data)
    {
        $self      = self::getInstance();

        $table     = $self->table_name;
        $param     = $self->makeUpdateParameter($data);
        $value     = $self->makeInsertParameter($data);

        $statement = "UPDATE {$table} SET {$param} ";
        $execute   = $self->exec($statement, $value);

        return $execute;
    }
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;
        }
    }
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();
    }
1269767
public function create($table, $data){
        $keys = array_keys($data);
        $values = ':' . implode(',:', $keys);
        $keys = implode(',', $keys);
        return $this->query($this->set("INSERT INTO {$table} ({$keys}) VALUES({$values})", $data));
    }
453460
protected function buildInsertStatement($data) {
        $fields = '';
        $values = '';
        $first = true;
        foreach($data as $data_key => $data_val) {
            $fields .= ($first?'':',')."`$data_key`";
            $values .= ($first?'':',')."?";
            $first = false;
        }
        $table_name = $this->getTableName();
        return "INSERT INTO `{$table_name}` ({$fields}) VALUES ({$values})";
    }
529384
public function set($table, $data, $tablePrefix = null)
    {
        if (is_array($data)) {
            is_null($tablePrefix) && $tablePrefix = $this->tablePrefix;

            $bulk = new BulkWrite();
            $insertId = $bulk->insert($data);
            $result = $this->runMongoBulkWrite($tablePrefix . $table, $bulk);

            Cml::$debug && $this->debugLogSql('BulkWrite INSERT', $tablePrefix . $table, [], $data);

            if ($result->getInsertedCount() > 0) {
                $this->lastInsertId = sprintf('%s', $insertId);
            }
            return $this->insertId();
        } else {
            return false;
        }
    }
1191015
public function insert($table, $data)
    {
        $fieldNames = implode(',', array_keys($data));
        $fieldValues = ':'.implode(', :', array_keys($data));

        $query = "INSERT INTO $table ($fieldNames) VALUES($fieldValues)";
        $this->prepare($query);

        /**
         * Iterate through data then bind the values
         */
        foreach ($data as $key => $value) {
            $this->bind(":$key", $value);
        }

        try {
            $this->execute();

            return true;
        } catch (PDOException $e) {
            echo $e->errorInfo[2];

            return false;
        }
    }
103933
public static function insert($table, array $set)
	{
		$query = 'INSERT INTO ' . self::escapeTableName($table) . ' SET ';
		$values = array ();
		foreach ($set as $k => $v) {
			$query .= $k . ' = ?, ';

			// No array? Then it's a simple string.
			if (is_array ($v)) {
				$values[] = $v;
			} else {
				$values[] = array($v);
			}
		}

		$query = substr($query, 0, -2);

		$query = new self($query);
		$query->bindValues($values);

		return $query;
	}
309596
public function insert($table, $data)
    {
        $query = $this->provider->buildInsertQuery($table, $data);

        return $this->provider->query($query, null);
    }