Import a record into a table, id field is required.
Basic safety checks only. Lobs are supported.
@param string $table name of database table to be inserted into
@param mixed $dataobject object or array with fields in the record
@return bool success
12849
public function import_record($table, $dataobject) {
        $dataobject = (object)$dataobject;

        $columns = $this->get_columns($table);
        $cleaned = array();
        foreach ($dataobject as $field=>$value) {
            if (!isset($columns[$field])) {
                continue;
            }
            $cleaned[$field] = $value;
        }

        return $this->insert_record_raw($table, $cleaned, false, true, true);
    }
395556
public static function insert($object)
    {
        $db = new DatabaseManager();
        $connection = $db->getDbh();

        $objectAsArrayForSqlInsert = DatatbaseUtility::objectToArrayLessId($object);
        $fields = array_keys($objectAsArrayForSqlInsert);
        $insertFieldList = DatatbaseUtility::fieldListToInsertString($fields);
        $valuesFieldList = DatatbaseUtility::fieldListToValuesString($fields);

        $statement = $connection->prepare('INSERT into '. static::getTableName()  . ' ' . $insertFieldList . $valuesFieldList);
        $statement->execute($objectAsArrayForSqlInsert);

        $queryWasSuccessful = ($statement->rowCount() > 0);
        if ($queryWasSuccessful) {
            return $connection->lastInsertId();
        } else {
            return -1;
        }
    }
271303
public function hasType($dataObjectClass)
    {
        foreach ($this->types as $scaffold) {
            if ($scaffold->getDataObjectClass() == $dataObjectClass) {
                return true;
            }
        }

        return false;
    }
435778
public function into($table, array $columns = [])
    {
        if (count($columns)) {
            $this->setColumns($columns);
        }

        return $this->addRootTable($table);
    }
1054060
public function insert($table, $values)
    {
        $keys = array();
        $params = array();
        $placeholders = array();
        foreach ($values as $k => $v) {
            $keys[] = $this->db->quoteColumn($k);
            $params[':' . $k] = $v;
            $placeholders[] = ':' . $k;
        }
        $sql = "INSERT INTO " . $this->db->quoteTable($table) . ' (' . implode(', ', $keys) . ') VALUES (' . implode(',', $placeholders) . ')';
        $result = $this->setSql($sql)->execute($params);
        if (!$result) {
            return false;
        }

        return $this->db->lastInsertId();
    }
879933
function isDatatable($table){
    if($table.dataTableSettings){
      for(var i = 0; i < $table.dataTableSettings.length; i++){
        var table = $table.dataTableSettings[i].nTable;
        if($table[0] == table){
          return true;
        }
      }
    }
    return false;
  }
1142404
public function select($table = null)
    {
        if ($this->table !== null && $table !== null) {
            throw new InvalidArgumentException(sprintf(
                'This Sql object is intended to work with only the table "%s" provided at construction time.',
                $this->table
            ));
        }

        return new \Dal\Db\Sql\Select(($table) ?: $this->table);
    }
519178
public function insert($table, array $data, $prepare = true)
    {
        if ($prepare) {
            $data = $this->prepareInsert($table, $data);
        }

        if (empty($data)) {
            return '0';
        }

        $keys = array_keys($data);
        $fields = implode(',', $keys);
        $values = ':' . implode(',:', $keys);

        $this->run("INSERT INTO $table ($fields) VALUES ($values)", $data);
        return $this->pdo->lastInsertId();
    }
275338
public function performMappingOnObject(DataObject $object)
    {
        //By default, we already have our data mapped in the object (hopefully properly)
        //But we do need to convert things that may need converting
        foreach ($this->mapping as $field => $variable) {
            $modifier = false;
            $newField = $variable;

            if (strpos($variable, ':') !== false) {
                list($newField, $modifier) = explode(':', $variable);
                $object->$newField = $this->getMappedValue($object, $newField, $variable);
            }
        }
    }
227259
public function addPrimaryAutoIncrementIdFieldToTable($table): bool
    {
        // Drop primary key - suspend error because we can have no primary index
        @$this->sql_query('ALTER IGNORE TABLE `' . $table . '` DROP PRIMARY KEY');
        // Create field and primary index
        $this->sql_query('ALTER IGNORE TABLE  `' . $table . '` ADD  `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST');

        return true;
    }
876773
public function addTableObject(TableMap $table)
    {
        $table->setDatabaseMap($this);
        $this->tables[$table->getName()] = $table;
        $this->tablesByPhpName[$table->getClassname()] = $table;
    }
575050
public function Insert($table, $data = array())
    {
        if (empty($table) || empty($data)) {
            return false;
        }

        //Before we set the columns, make sure we only use the column that re meant to be filled.
        foreach ($data as $key => $val) {
            if (empty($val)) {
                unset($data[$key]);
            }
        }

        //Get all the columns that are being set
        $columns = array_keys($data);

        //If the columns are not empty, proceed with the save
        if (!empty($columns)) {
            //Create a newInsert object
            $insert = $this->queryFactory->newInsert();

            //Set the table
            $insert->into($table);

            //Set the columns
            $insert->cols($columns);

            //Bind the values to be saved
            $insert->bindValues($data);

            //return the insert id
            return $this->exec($insert->getStatement(), $insert->getBindValues());

        }

        return false;
    }
1121374
private function initializeDataContainer($table, $field)
    {
        // Define the current ID
        if (!defined('CURRENT_ID')) {
            define('CURRENT_ID', $table ? \Session::getInstance()->get('CURRENT_ID') : $field);
        }

        static::loadDataContainer($table);

        $this->dca     = &$GLOBALS['TL_DCA'][$table];
        $driverClass   = 'DC_' . $this->dca['config']['dataContainer'];
        $dataContainer = new $driverClass($table);

        $dataContainer->field = $field;

        if (!isset($this->dca['fields'][$field]) || $this->dca['fields'][$field]['inputType'] != 'icon') {
            throw new \RuntimeException('Invalid call. Field does not exists or is not an icon wizard');
        }

        $values = $dataContainer->activeRecord->$field;

        // Call the load_callback
        if (is_array($this->dca['fields'][$field]['load_callback'])) {
            foreach ($this->dca['fields'][$field]['load_callback'] as $callback) {
                $values = $this->triggerCallback($callback, array($values, $dataContainer));
            }
        }

        // support options callback
        if (isset($this->dca['fields'][$field]['options_callback'])) {
            $this->dca['fields'][$field]['options'] = $this->triggerCallback(
                $this->dca['fields'][$field]['options_callback'],
                array($dataContainer)
            );
        }

        return $dataContainer;
    }
516384
public function addTableObject(TableMap $table)
    {
        $table->setDatabaseMap($this);
        $this->tables[$table->getName()] = $table;
        $phpName = $table->getClassName();
        if ('\\' !== $phpName[0]) {
            $phpName = '\\' . $phpName;
        }
        $this->tablesByPhpName[$phpName] = $table;
    }
970558
public function insert($table = null)
    {
        $this->type = self::TYPE_INSERT;
        if ($table) {
            $this->table($table);
        }

        return $this;
    }
47103
public function addTable($table)
    {
        $this->nextTableId++;
        $this[$this->nextTableId] = $table;
        return $this->nextTableId;
    }
1336884
public function loadFrom(DataObjectInterface $record)
    {
        $fieldName = $this->getName();
        if (empty($fieldName) || empty($record)) {
            return;
        }

        $relation = $record->hasMethod($fieldName)
            ? $record->$fieldName()
            : null;

        // Detect DB relation or field
        if ($relation instanceof Relation) {
            // Load ids from relation
            $value = array_values($relation->getIDList());
            parent::setValue($value);
        } elseif ($record->hasField($fieldName)) {
            // Load dataValue from field... a CSV for DBMultiEnum
            if ($record->obj($fieldName) instanceof DBMultiEnum) {
                $value = $this->csvDecode($record->$fieldName);

            // ... JSON-encoded string for other fields
            } else {
                $value = $this->stringDecode($record->$fieldName);
            }

            parent::setValue($value);
        }
    }