Insert a new field in the database
We assume the field object is already defined as $this->field

@global object
@return bool
16876
function insert_field() {
        global $DB, $OUTPUT;

        if (empty($this->field)) {
            echo $OUTPUT->notification('Programmer error: Field has not been defined yet!  See define_field()');
            return false;
        }

        $this->field->id = $DB->insert_record('data_fields',$this->field);

        // Trigger an event for creating this field.
        $event = \mod_data\event\field_created::create(array(
            'objectid' => $this->field->id,
            'context' => $this->context,
            'other' => array(
                'fieldname' => $this->field->name,
                'dataid' => $this->data->id
            )
        ));
        $event->trigger();

        return true;
    }
1272515
public function add_fields( $fields )
	{
		if ( !is_array( $fields ) )
		{
			$fields = array( $fields );
		}
		
		// merge the new values with the existing ones.
		$this->fields = array_merge( $this->fields, $fields ); 
	
		// return self so we can continue running the next function
		return $this;
	}
780301
public function _add() {
		$model = $this->model;
		$instance = new $model ();
		$this->operate_ ( $instance, function ($instance) {
			$datas = $this->getDatas ();
			$this->_setValuesToObject ( $instance, $datas );
			if ($this->_validateInstance ( $instance, $datas )) {
				return $this->AddOperation ( $instance, $datas, true );
			}
			return null;
		}, "inserted", "Unable to insert the instance", [ ] );
	}
421105
protected function _buildInsert()
        {
            $query[] = "INSERT INTO";
            $query[] = $this->_quoteIdentifier($this->_table_name);
            $field_list = array_map(array($this, '_quoteIdentifier'), array_keys($this->_dirty_fields));
            $query[] = "(" . join(", ", $field_list) . ")";
            $query[] = "VALUES";

            $placeholders = $this->_createPlaceholders($this->_dirty_fields);
            $query[] = "({$placeholders})";

            if (self::get_db($this->_connection_name)->getAttribute(PDO::ATTR_DRIVER_NAME) == 'pgsql') {
                $query[] = 'RETURNING ' . $this->_quoteIdentifier($this->_getIdColumnName());
            }

            return join(" ", $query);
        }
462956
protected function performInsert()
    {
        if ($this->fireModelEvent('creating') === false) {
            return false;
        }

        // First we'll need to create a fresh query instance and touch the creation and
        // update timestamps on this model, which are maintained by us for developer
        // convenience. After, we will just continue saving these model instances.
        if ($this->usesTimestamps()) {
            $this->updateTimestamps();
        }

        $attributes = $this->attributes;

        if (empty($attributes)) {
            return true;
        }

        $updated = static::$client::create($attributes);

        if (array_has($updated, $keyName = $this->getKeyName())) {
            $this->setAttribute($keyName, array_get($updated, $keyName));
        }

        // We will go ahead and set the exists property to true, so that it is set when
        // the created event is fired, just in case the developer tries to update it
        // during the event. This will allow them to do so and run an update here.
        $this->exists = true;

        $this->wasRecentlyCreated = true;

        $this->fireModelEvent('created', false);

        return true;
    }
39274
protected function _insert()
    {

        // set oxcreate date
        $this->oxuser__oxcreate = new \OxidEsales\Eshop\Core\Field(date('Y-m-d H:i:s'), \OxidEsales\Eshop\Core\Field::T_RAW);

        if (!isset($this->oxuser__oxboni->value)) {
            $this->oxuser__oxboni = new \OxidEsales\Eshop\Core\Field($this->getBoni(), \OxidEsales\Eshop\Core\Field::T_RAW);
        }

        return parent::_insert();
    }
1318630
public function save()
    {
        $result;
        if (! self::$id) {
            // new record so we insert
            $query = "INSERT INTO $this->tableName (".implode(", ", array_keys($this->props)).") VALUES(";

            for ($i = 0; $i < count($this->props); $i++) {
                $query .= "?";

                if ($i != count($this->props) - 1) {
                    $query .= ",";
                }
            }

            $query .= ");";

            $insert = Connection::db()->prepare($query);
            $result = $insert->execute(array_values($this->props));
        } else {
            // existing record, se we update
            $query = "UPDATE $this->tableName SET ";

            $count = 0;
            foreach ($this->props as $key => $value) {
                $query .= "$key = '$value'";

                if ($count != count($this->props) - 1) {
                    $query .= ",";
                }
                $count++;
            }

            $query .= " WHERE id = ".self::$id;
            $result = Connection::db()->query($query);
        }

        if (! $result) {
            return false;
        } else {
            return true;
        }
    }
1121354
public function add_field($name,$aliase=false){
		if ($aliase===false) $aliase=$name;
		
		//adding to list of data-active fields
		if ($this->id["db_name"]==$name || $this->relation_id["db_name"] == $name){
			LogMaster::log("Field name already used as ID, be sure that it is really necessary.");
		}
		if ($this->is_field($name,$this->text)!=-1)
			throw new Exception('Data field already registered: '.$name);
		array_push($this->text,array("db_name"=>$name,"name"=>$aliase));
		
		//adding to list of all fields as well
		if ($this->is_field($name,$this->data)==-1)
			array_push($this->data,array("db_name"=>$name,"name"=>$aliase));
		
	}
1049605
public function insertId(){
		if($this->type !== Manager::STMT_INSERT)
			throw new LogicException(__METHOD__ . ' can be called only on INSERT statements.');

		$this->performed || $this->run();
		try{
			return $this->connection->getDriver()->getInsertId();
		} catch(ImplementationException $e){
			return false;
		}
	}
1026552
final public function create() {

		$app = Application::getInstance();
		$class = get_called_class();
		
		if (!$this->areKeysPopulated() and !$this->db->isAutoIncrement(static::TABLE_NAME)) {
			$app->logEvent('The object’s ' . implode(', ', $this->keyProperties) . ' properties must be populated in order to create a ' . $class . ' record');
			return FALSE;
		}
		
		// hook for tasks to be executed before creation
		$this->beforeCreate();
		
		// get list of class property names
		$props = array_keys(static::getBinds());
		
		// insert the object as db record
		$dbObj = $this->prepareData($props);
		$res = $this->db->insertObject(static::TABLE_NAME, $dbObj);

		// get last insert id if not compound key
		if (!static::hasCompoundKey()) {

			$lastInsertId = $this->db->getLastInsertId();
		
			$key = $this->keyProperties[0];
			
			if ('int' == $this->getPropertyType($key)) {
				$this->{$key} = (int)$lastInsertId;
			} else {
				$this->{$key} = $lastInsertId;
			}
			
		}

		// set logs
		$keyParts = array();
			
		foreach ($this->keyProperties as $prop) {
			$keyParts[] = $prop . '=' . $this->{$prop};
		}
		
		// log as application event
		$app->logEvent('Created a new ' . $class . ' object with ' . implode(', ' , $keyParts));
		
		// hook for tasks to be executed after creation
		$this->afterCreate();
		
		return (bool)$res;
	
	}
624703
public function addField(Field $field)
    {
        $this->fields->set($field->getColumn(), $field);
        
        return $this;
    }
1142771
protected function _insert()
    {
        // marking basket as not new any more
        $this->_blNewBasket = false;

        if (!isset($this->oxuserbaskets__oxpublic->value)) {
            $this->oxuserbaskets__oxpublic = new \OxidEsales\Eshop\Core\Field(1, \OxidEsales\Eshop\Core\Field::T_RAW);
        }

        $iTime = \OxidEsales\Eshop\Core\Registry::getUtilsDate()->getTime();
        $this->oxuserbaskets__oxupdate = new \OxidEsales\Eshop\Core\Field($iTime);

        return parent::_insert();
    }
754698
public function add()
    {
        $entity = $this->Dblists->newEntity();
        if ($this->request->is('post')) {
            $entity = $this->Dblists->patchEntity($entity, (array)$this->request->getData());
            if ($this->Dblists->save($entity)) {
                $this->Flash->success('The database list has been saved.');

                return $this->redirect(['action' => 'index']);
            }

            $this->Flash->error('The database list could not be saved. Please, try again.');
        }

        $this->set(compact('entity'));
        $this->set('_serialize', ['entity']);
    }
159238
public function insert()
    {
        $result = $this->connection()->post($this->getEndpoint(), $this->jsonWithNamespace());

        return $this->selfFromResponse($result);
    }
509971
protected function setFields()
    {
        $this->tableFields = new \stdClass();
        foreach ($this->schema() as $field => $type)
            $this->tableFields->{$field} = (Validate::isNumeric($type) and $field != $this->databaseConfig->getIdentifier()) ? 0 : null;
        $this->clearIdentifier();
        return $this;            
    }
833815
public function add()
    {
        $this->view = 'scaffold/add';
        $form = new Form(
            "add-{$this->get('modelSingular')}", $this->getDescriptor()
        );
        if ($this->request->isPost()) {
            $form->setData($this->request->getPost());
            if ($form->isValid()) {
                try {
                    $modelClass = $this->getModelName();
                    /** @var Model $model */
                    $model = new $modelClass($form->getValues());
                    $model->save();
                    $name = ucfirst($this->get('modelSingular'));
                    $this->addSuccessMessage(
                        "{$name} successfully created."
                    );
                    $pmk = $model->getPrimaryKey();
                    $this->redirect(
                        $this->_basePath .'/'.
                        $this->get('modelPlural').'/show/'.$model->$pmk
                    );
                    return;
                } catch (Database\Exception $exp) {
                    $this->addErrorMessage(
                        "Error while saving {$this->get('modelSingular')}} " .
                        "data: {$exp->getMessage()}"
                    );
                }
            } else {
                $this->addErrorMessage(
                    "Cannot save {$this->get('modelSingular')}. " .
                    "Please correct the errors bellow."
                );
            }
        }
        $descriptor =  $this->getDescriptor();
        $this->set(compact('form', 'descriptor'));
    }
769782
def insert(self):
        """"""
        self.default_val = 0
        #fields = self.fields
        #fields = self.orm_class.depart(self.fields, is_update=False)
        #self.set_fields(fields)
        return self.interface.insert(
            self.schema,
            self.fields
        )

        return self.interface.insert(self.schema, self.fields)