Filter fields to insert/update table

@access public
@param string $table
@param array $data
@return $filtered_data
348720
private function filter_table_data($table, $data) {
		$table_fields = $this->get_columns($table);
		$result = [];

		foreach ($table_fields as $field) {
			if (array_key_exists($field, $data)) {
				$result[ $field ] = $data[$field];
			}
		}

		if (count($data) == 0) {
			return [];
		}
		return $result;
	}
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;
        }
    }
9723
public static function insert($table, $data) {
        $insert = Insert::table($table);
        foreach ($data as $field => $value) {
            $insert->set($field, $value);
        }
        return $insert->excuse();
    }
1004090
public function insertUpdate(array $data)
    {
        $affected = $this->update($data);
        return $affected ?: $this->insert($data);
    }
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);
    }
194534
public function filter($table)
    {
        if (empty($this->metadataColumn) || empty($this->valueToPrepend)) {
            return;
        }

        $metadataColumn = $this->metadataColumn;
        $valueToPrepend = $this->valueToPrepend;

        $table->filter(function (DataTable $dataTable) use ($metadataColumn, $valueToPrepend) {
            foreach ($dataTable->getRows() as $row) {
                $filter = $row->getMetadata($metadataColumn);
                if ($filter !== false) {
                    $row->setMetadata($metadataColumn, $valueToPrepend . $filter);
                }
            }
        });
    }
448960
public function insertPDO($table, array $data = array())
    {
        if (count($data) === 0) {
            return false;
        }
        $q = "INSERT INTO `$table` ";
        $v = '';
        $n = '';

        foreach ($data as $key => $val) {
            $n .= "`$key`, ";
            if (strtolower($val) === 'now()') {
                $v .= 'NOW(), ';
                unset($data[$key]);
            } else {
                $v .= '?, ';
            }
        }
        $q .= '(' . rtrim($n, ', ') . ') VALUES (' . rtrim($v, ', ') . ');';
        try {
            $this->_queryId = self::$_linkId->prepare($q);

            $i = 1;
            foreach ($data as $key => $val) {
                $type = $this->getPDOConstantType($val);
                $this->_queryId->bindValue($i, $val, $type);
                ++$i;
            }
            $this->_queryId->execute();
            return self::$_linkId->lastInsertId();
        } catch (PDOException $e) {
            $this->_error = $e->getMessage();
            return false;
        }
    }
309596
public function insert($table, $data)
    {
        $query = $this->provider->buildInsertQuery($table, $data);

        return $this->provider->query($query, null);
    }
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);
    }
905430
private function _insert_replace( $table, $data, $method ) {
		if ( ! isset( $this->table_defines[ $table ] ) ) {
			return false;
		}
		if ( $method !== 'insert' && $method !== 'replace' ) {
			return false;
		}
		if ( $method === 'replace' && ! isset( $data['id'] ) ) {
			return false;
		}

		/** @var \wpdb $wpdb */
		global $wpdb;
		$columns = $this->table_defines[ $table ]['columns'];

		$data = $this->set_update_params( $data, $method === 'insert', true, false );
		list ( $_data, $_format ) = $this->filter( $data, $columns );

		return $wpdb->$method( $this->get_table( $table ), $_data, $_format );
	}
1190677
public function create(string $table, array $data)
    {
        $data['created_at']=time();
        $this->db->insert($table, $data);
        $id=$this->db->id();
        if ($id) {
            return $id;
        } else {
            return false;
        }
    }
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));
    }
873476
public function insert(array $data, $table = null)
    {
        $table = ($table) ?: $this->getTable();
        $sql = $this->getSql();
        $insert = $sql->insert($table);

        $insert->values($data);

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

        return $result->getGeneratedValue();
    }
355658
public function filter($table)
    {
        foreach ($table->getRows() as $row) {
            $value = $row->getColumn($this->columnToDecode);
            if ($value !== false) {
                $value = self::decodeLabelSafe($value);
                $row->setColumn($this->columnToDecode, $value);

                $this->filterSubTable($row);
            }
        }
    }
866022
public function insert($table, $data) {
        if (!$this->validateTableAndCol($table, array_keys($data))) {
            throw new \InvalidArgumentException ('Table or coloumn information is incorrect acorrding to the contract');
        }

        if ($data && !$this->validateBind($table, $data)) {
            throw new \InvalidArgumentException ('Input data is incorrect acorrding to the contract');
        }

        $result = $this->db_adapter->insert($table, $data);
        if (!$result) {
            throw new \InvalidArgumentException ($this->db_adapter->getLastError());
        }   

        return $result;
    }
693152
public function filter($table)
    {
        $row = new DataTableSummaryRow($table);
        $row->setColumn('label', $this->labelSummaryRow);
        $table->addSummaryRow($row);
    }
824257
public function insert(array $data)
    {
        $this->normalizeDataColumns($data);

        $this->setSearchIndexableData($data);

        return $this->app['db']->insert($this->getTable(), $data);
    }