Create new fields from JSON data.

@param mixed[] $data JSON data
@param string $table Table name
@return void
968761
private function createFromCsv(array $data, string $table) : void
    {
        foreach ($data as $col) {
            $csvField = new CsvField($col);
            $dbFields = $this->factory->fieldToDb($csvField, $table);

            if (empty($dbFields)) {
                continue;
            }

            foreach ($dbFields as $dbField) {
                $this->createColumn($dbField);
            }
        }
    }
416429
public function rows(array $data): void
    {
        $this->rows = $data;
        $pdoStatement = $this->provideStatement();
        $this->execute($pdoStatement);
    }
20375
public function add( $data )
	{
		$columnNum = 0;
		$rowNum = $this->_iterator->current()->getRowIndex();

		foreach( (array) $data as $value ) {
			$this->_sheet->setCellValueByColumnAndRow( $columnNum++, $rowNum, $value );
		}

		$this->_iterator->next();
	}
1248355
protected static function makeMultipleInsert($table, $data)
    {
        $insert_values = array();

        foreach ($data as $d) {
            $insert_values = array_merge($insert_values, array_values($d));

            $count = count($d);
            $array = array_fill(0, $count, '?');

            $placeholder[] = '('.implode(',', $array).')';
        }

        $column = implode(',', array_keys($data[0]));
        $values = implode(',', $placeholder);

        $query  = "INSERT INTO {$table} ({$column}) VALUES {$values}";

        return [$query, $insert_values];
    }
143355
public function insert($table, $data = [])
    {
        // check if table name not empty
        if (!empty($table)) {
            // and array data not empty
            if (count($data) > 0 && is_array($data)) {
                // get array insert data in temp array
                $tmp = [];
                foreach ($data as $f => $v) {
                    $tmp[] = ":s_$f";
                }
                // make name space param for pdo insert statement
                $sNameSpaceParam = implode(',', $tmp);
                // unset temp var
                unset($tmp);
                // get insert fields name
                $sFields = implode(',', array_keys($data));
                // set pdo insert statement in class property
                $this->sql = "INSERT INTO `$table` ($sFields) VALUES ($sNameSpaceParam);";
                // pdo prepare statement
                $this->STH = $this->prepare($this->sql);
                // set class where property with array data
                $this->data = $data;
                // bind pdo param
                $this->_bindPdoNameSpace($data);
                // use try catch block to get pdo error
                try {
                    // execute pdo statement
                    if ($this->STH->execute()) {
                        // set class property with last insert id
                        $this->lastId = $this->lastInsertId();
                        // close pdo
                        $this->STH->closeCursor();
                        // return this object
                        return $this;
                    } else {
                        self::error($this->STH->errorInfo());
                    }
                } catch (\PDOException $e) {
                    // get pdo error and pass on error method
                    self::error($e->getMessage() . ': ' . __LINE__);
                }
            } else {
                self::error('Data not in valid format..');
            }
        } else {
            self::error('Table name not found..');
        }
    }
60876
public static function insert($table, $data = array(), $config = array()) {
        DB::connect();
        return DB::$connection->insert($table, $data, $config);
    }
437957
public function setFromArray(array $data): void
	{
		foreach ($data as $parameter => $value) {
			$this->bindings[$parameter] = new Bind($parameter, $value);
		}
	}
511371
public function setData(string $table, $data){
            
            $file = $this->base . '/' . $table . '.json';
            if(file_exists($file)){
                if(file_put_contents($file, json_encode($data))){
                    $status = true;
                }else{
                    $status = false;
                }
                return new \NonDB\Components\Status($status);
            }else{
                throw new \NonDB\Exceptions\DriverException('Table Not Exists.', 1002);
            }

        }
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
    }
1152497
public function export_table_data(xmldb_table $table, $data) {
        $this->importer->import_table_data($table->getName(), $data);
    }
114344
public static function createFromDecodedJsonResponse($data)
    {
        $areas = [];
        foreach ($data as $name => $area) {
            $areas[$name] = [];
            foreach ($area as $class => $data) {
                $metaClass = DynamicMetadataHelper::getDynamicMetadataClassName($class);
                /* @var DynamicMetadataInterface $metaClass */
                $areas[$name][] = $metaClass::createFromDecodedJsonResponse($data);
            }
        }

        return new self($areas);
    }
607900
public function insertBatch(string $table, array $data=[]): array
	{
		$data = (array) $data;
		$firstRow = (array) current($data);

		// Values for insertion
		$vals = [];
		foreach($data as $group)
		{
			$vals = array_merge($vals, array_values($group));
		}
		$table = $this->quoteTable($table);
		$fields = array_keys($firstRow);

		$sql = "INSERT INTO {$table} ("
			. implode(',', $this->quoteIdent($fields))
			. ') VALUES ';

		// Create the placeholder groups
		$params = array_fill(0, count($fields), '?');
		$paramString = '(' . implode(',', $params) . ')';
		$paramList = array_fill(0, count($data), $paramString);

		// Append the placeholder groups to the query
		$sql .= implode(',', $paramList);

		return [$sql, $vals];
	}
859988
private function updateFromCsv(array $data, string $table, array $fields) : void
    {
        $tableFields = [];
        // get existing table column names
        foreach ($fields as $field) {
            $tableFields[] = $field->getName();
        }

        // keep track of edited columns
        $editedColumns = [];
        foreach ($data as $col) {
            $csvField = new CsvField($col);
            $dbFields = $this->factory->fieldToDb($csvField, $table);

            if (empty($dbFields)) {
                continue;
            }

            foreach ($dbFields as $dbField) {
                // edit existing column
                if (in_array($dbField->getName(), $tableFields)) {
                    $editedColumns[] = $dbField->getName();
                    $this->updateColumn($dbField);
                } else { // add new column
                    $this->createColumn($dbField);
                }
            }
        }

        // remove unneeded columns
        foreach (array_diff($tableFields, $editedColumns) as $fieldName) {
            $this->deleteColumn($fieldName);
        }
    }
1033823
public function export_table_data(xmldb_table $table, $data) {
        $this->output('<record>');
        foreach ($data as $key => $value) {
            if (is_null($value)) {
                $this->output('<field name="'.$key.'" value="null" />');
            } else {
                $this->output('<field name="'.$key.'">'.htmlspecialchars($value, ENT_NOQUOTES, 'UTF-8').'</field>');
            }
        }
        $this->output('</record>');
    }
77197
public function create(array $data)
    {
        // Creates the keys string
        $keys = implode(', ', array_keys($data));

        // Creates the values string
        $values = implode('", "', $data);

        // Creates the query with the $data array keys & values
        $query = 'INSERT INTO ' . $this->table . ' (' . $keys . ') VALUES ("' . $values . '")';

        // Executes the query
        $this->database->action($query);
    }
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;
    }
797345
private function addVerticesFromArray(array $data)
    {
        $_documentClass = $this->_documentClass;

        $this->_result[] = $_documentClass::createFromArray($data, $this->_options);
    }