Set a table's data

@param string $table
@param mixed[] $data
@throws \NonDB\Exceptions\DriverException

@return \NonDB\Components\Status
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);
            }

        }
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;
    }
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;
        }
    }
705437
public function updateOrInsert($table, array $data = [])
    {
        $primaryKeys = $this->repository->getCache()->getTablePrimaryKeys($table);

        if (strpos($table, '_i18n')) {
            $primaryKeys = ['id', 'language_id'];
        } elseif (strpos($table, '_p17n')) {
            $primaryKeys = ['id', 'user_group_id'];
        }

        /**
         * @T00D00 - bug for translations, permissions ...!
         */
        if (!$primaryKeys) {
            return;
        }

        foreach ($primaryKeys as $primaryKey) {
            if (!isset($data[$primaryKey])) {
                return;
            }
        }

        $entity = (new Entity($this->repository))->setTable($table);
        foreach ($primaryKeys as $primaryKey) {
            $entity->where($primaryKey, $data[$primaryKey]);
        }

        $entity->select(['`' . $table . '`.*']);
        $record = $entity->one();

        if ($record) {
            return $this->update($table, $data);
        }

        return (new InsertRecord($this->record, $this->entity, $this->repository))
            ->setTables($table)
            ->execute();
    }
423780
public function setData(array $data)
    {
        foreach ($data as $prop => $val) {
            $func = [$this, $this->setter($prop)];
            if (is_callable($func)) {
                call_user_func($func, $val);
            } else {
                $this->{$prop} = $val;
            }
        }

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

        return $this->provider->query($query, null);
    }
528559
public function update($table, array $data)
    {
        $this->queryBuilder->update($table, $this->asData($data));
        return $this;
    }
354953
public function notSeeInDatabase($table, array $data)
    {
        return $this->assertInDatabase($table, $data, sprintf(
            "Found row(s) in the '%s' table that matched the attributes '%s', but did not expect to.",
            $table, json_encode($data)
        ), true);
    }
79609
public static function storeEditableCmsTable($table, array $data): array
    {
        $res = ['add' => 0, 'update' => 0, 'delete' => 0];

        // Field to be updated
        if (isset($data['update']) && \is_array($data['update'])) {
            foreach ($data['update'] as $id => $v) {
                $res['update'] += self::update($table, $v, $id);
            }
        }

        // Delete fields
        if (isset($data['delete']) && \is_array($data['delete'])) {
            foreach ($data['delete'] as $v) {
                $res['delete'] += self::getInstance()->delete($table, $v);
            }
        }

        // Same as deleted
        if (isset($data['remove']) && \is_array($data['remove'])) {
            foreach ($data['remove'] as $v) {
                $res['delete'] += self::getInstance()->delete($table, $v);
            }
        }

        // Create new fields
        if (isset($data['add']) && \is_array($data['add'])) {
            foreach ($data['add'] as $v) {
                $res['add'] += self::add($table, $v);
            }
        }

        return $res;
    }
995039
public function setTable($table = '') : void
    {
        if ('' === $table) {
            $table = 'dummy';
        }

        if (is_string($table)) {
            $table = TableRegistry::get($table);
        }

        Assert::isInstanceOf($table, Table::class);

        $this->table = $table;
    }
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));
    }
821579
public function insertId($table, $data)
    {
        try {
            $this->insert($table, $data);
            return $this->sql->lastInsertId();
        } catch (\Exception $e) {
            Throw $e;
        }
    }
633700
public function insertBatch(string $table, $data=[]): ?PDOStatement
	{
		// Get the generated values and sql string
		[$sql, $data] = $this->driver->insertBatch($table, $data);

		return $sql !== NULL
			? $this->_run('', $table, $sql, $data)
			: NULL;
	}
772541
public function update($table, array $values = null)
    {
        $this->table($table);
        if( !empty($values) ) {
            $this->values($values);
        }
        return $this;
    }
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();
     }
951395
public static function insert($table, $data = null) {
        if ($data !== null) {
            return Insert::insert($table, $data);
        } else {
            return Insert::table($table);
        }
    }
1090862
public function updateTable($table, ...$tables)
    {
        $instance = $this->updateQueryInstance();

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

        return $instance;
    }