insert new record into the DB table
returns new record ID if insertion was successful, otherwise -1
@param Object $object
@return integer
167234
public function create($object)
    {
        $db = new DatabaseManager();
        $connection = $db->getDbh();

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

        $sql = 'INSERT into :table :insertFieldList :valuesFieldList';
        $sql = str_replace(':table', $this->tableName, $sql);
        $sql = str_replace(':insertFieldList', $insertFieldList, $sql);
        $sql = str_replace(':valuesFieldList', $valuesFieldList, $sql);

        $statement = $connection->prepare($sql);
        $statement->execute($objectAsArrayForSqlInsert);

        $queryWasSuccessful = ($statement->rowCount() > 0);
        if($queryWasSuccessful) {
            return $connection->lastInsertId();
        } else {
            return -1;
        }
    }
249857
private function _updateObjectIndexes($object)
    {
        //delete all indexed references to this object
        $update = Statement::get(
            'DELETE_OBJECT_INDEX',
            [
                '@collection' => $this->_name,
                '@id' => $this->_connector->quote($object->__id)
            ]
        );
        //parse each property of the object an attempt to index each value
        foreach (get_object_vars($object) as $property => $value) {
            if (
                $this->_isPropertyIndexable($property)
                && $this->_isValueIndexable($value)
            ) {
                $insert = Statement::get(
                    'INSERT_OBJECT_INDEX',
                    [
                        '@collection' => $this->_name,
                        '@type' => $this->_connector->quote('value'),
                        '@prop' => $this->_connector->quote($property),
                        '@val' => $this->_connector->quote($value),
                        '@id' => $this->_connector->quote($object->__id),
                        '@origin' => $this->_connector->quote($object->__origin)
                    ]
                );
                $update .= $insert;
            }
        }
        //add the object registry index
        $insert = Statement::get(
            'INSERT_OBJECT_INDEX',
            [
                '@collection' => $this->_name,
                '@type' => $this->_connector->quote('registry'),
                '@prop' => $this->_connector->quote(''),
                '@val' => $this->_connector->quote(''),
                '@id' => $this->_connector->quote($object->__id),
                '@origin' => $this->_connector->quote($object->__origin)
            ]
        );
        $update .= $insert;
        //execute all the sql to update indexes.
        $this->_connector->exec($update);
    }
1111261
public function insert(\Berthe\VO $object)
    {
        $this->validateTableAndIdentityColumn();

        $mappings = $this->getSaveMappings();

        if (empty($mappings)) {
            $mappings = $this->getDefaultMappings($object);
        }

        $valueElements = array();
        $columnElements = array();
        $params = array();

        $values = $object->__toArray();

        foreach ($mappings as $column => $property) {
            if ($column != $this->identityColumn) {
                $value = in_array($property, $object->getTranslatableFields()) ?
                    $object->getAttribute($property) :
                    $values[$property];
                $columnElements[] = $column;
                $params[$column] = $value;

                if ($value instanceof \Berthe\Translation\Translation) {
                    $this->translator->saveTranslation($value);
                }
            }
        }

        $columnAssignment = $this->escapeCharacter .
            implode($this->escapeCharacter . ', ' . $this->escapeCharacter, $columnElements) .
            $this->escapeCharacter;
        $valueAssignment = '%s' . str_repeat(', %s', count($columnElements) -1);

        $query = <<<EOQ
INSERT INTO {$this->getTableName()} ({$columnAssignment})
VALUES ({$valueAssignment});
EOQ;

        if ((bool)$this->db->query($query, $params)) {
            $id = (int)$this->db->lastInsertId($this->getTableName(), $this->identityColumn);
            $object->setId($id);
        }

        return $object->getId() > 0;
    }
1010489
public function insertOne(array $record): int
    {
        $method = 'addRecord';
        if (70400 > PHP_VERSION_ID && '' === $this->escape) {
            $method = 'addRFC4180CompliantRecord';
        }

        $record = array_reduce($this->formatters, [$this, 'formatRecord'], $record);
        $this->validateRecord($record);
        $bytes = $this->$method($record);
        if (false !== $bytes && 0 !== $bytes) {
            return $bytes + $this->consolidate();
        }

        throw CannotInsertRecord::triggerOnInsertion($record);
    }
945990
public function delete($object)
	{
		$deleted = $object->delete();

		if( ! $deleted)
		{
			return new Payload($object, 'not_deleted');
		}

		// Remove the deleted model from cache.
		Cache::tags($this->model->getTable())->flush($updated->getKey());

		return new Payload(null, 'deleted');
	}
125028
public function update($object)
    {
        $id = $object->getId();

        $db = new DatabaseManager();
        $connection = $db->getDbh();

        $objectAsArrayForSqlInsert = DatatbaseUtility::objectToArrayLessId($object);
        $fields = array_keys($objectAsArrayForSqlInsert);
        $updateFieldList = DatatbaseUtility::fieldListToUpdateString($fields);

        $sql = 'UPDATE :table SET :updateFieldList WHERE id=:id';
        $sql = str_replace(':table', $this->tableName, $sql);
        $sql = str_replace(':updateFieldList', $updateFieldList, $sql);

        $statement = $connection->prepare($sql);

        // add 'id' to parameters array
        $objectAsArrayForSqlInsert['id'] = $id;

        $queryWasSuccessful = $statement->execute($objectAsArrayForSqlInsert);

        return $queryWasSuccessful;
    }
1242006
public static function parse_object_id( $object ) {
		if ( is_numeric( $object ) && $object > 0 ) {
			return (int) $object;
		} elseif ( ! empty( $object->ID ) ) {
			return (int) $object->ID;
		} elseif ( ! empty( $object->term_id ) ) {
			return (int) $object->term_id;
		} elseif ( $object instanceof WP_Object ) {
			return $object->get_id();
		}
	}
906918
protected static function createFromObjectForAdditional($object)
    {
        $indexProperty = null;
        $class = null;

        if (property_exists($object, 'anyOf')) {
            $indexProperty = 'anyOf';
            $class = AnyOf::class;
        } elseif (property_exists($object, 'allOf')) {
            $indexProperty = 'allOf';
            $class = AllOf::class;
        } elseif (property_exists($object, 'oneOf')) {
            $indexProperty = 'oneOf';
            $class = OneOf::class;
        } else {
            return null;
        }

        //Parse index property's object as validator
        foreach ($object->{$indexProperty} as &$property) {
            $property = BaseValidator::createFromObject($property);
        }

        $validator = new $class($object->{$indexProperty});

        return $validator;
    }
589883
public function equalsTo(Object $object)
    {
        if (!$this->sameTypeAs($object)) {
            throw new NotMatchTypeException($this);
        }

        return $this->getId()->id() === $object->getId()->id();
    }
523761
public function add($object)
    {
        if (!is_object($object) || !($object instanceof $this->objectType)) {
            $type = (is_object($object) ? get_class($object) : gettype($object));
            throw new IllegalObjectTypeException('The value given to add() was ' . $type . ' , however the ' . get_class($this) . ' can only store ' . $this->objectType . ' instances.', 1517408062);
        }
        $this->entityManager->persist($object);
    }
1177519
public function persist($object, $collection = null)
    {
        $repository = $this->getRepository(get_class($object), $collection);
        $repository->getClassMetadata()->getEventManager()->execute(EventManager::EVENT_PRE_PERSIST, $object);
        $this->addObject($object, ObjectManager::OBJ_NEW, $repository);
        $repository->getClassMetadata()->getEventManager()->execute(EventManager::EVENT_POST_PERSIST, $object);

        return $this;
    }
687286
public static function insert($record)
    {
        $instance = new static();
        if ($fields = array_diff(array_keys($record), $instance->_di->modelsMetadata->getAttributes($instance))) {
            $instance->logger->debug(['insert `:1` table skip fields: :2', $instance->getSource(), array_values($fields)]);

            foreach ($fields as $field) {
                unset($record[$field]);
            }
        }

        $instance->getConnection($record)->insert($instance->getSource($record), $record);

        return 1;
    }
871081
public function save($object)
    {
        if (method_exists($object, 'getContenttype')) {
            $entityName = $object->getContenttype();
        } else {
            $entityName = get_class($object);
        }
        $repo = $this->getRepository($entityName);

        return $repo->save($object);
    }
396472
protected function sortObject($object)
    {
        $sort_array = get_object_vars($object);
        ksort($sort_array);

        $new_object = new stdClass();
        foreach ($sort_array as $key => $value) {
            if (is_object($value)) {
                $value = $this->sortObject($value);
            }
            $new_object->$key = $value;
        }

        unset($sort_array);
        unset($object);

        return $new_object;
    }
1353009
protected function registerNew(PersistentObject $object) {
    $key = $object->getOID()->__toString();
    if (self::$isDebugEnabled) {
      self::$logger->debug("Register new object: ".$key);
    }
    $this->newObjects[$key] = $object;
    $this->observedObjects[$key] = $object;
    return $object;
  }
160458
public function get($object_id = 0, $where = '')
	{
		return new Record($object_id, $this->db, $this->table, $this->primary, $where, $this->select);
	}
881682
public function push($object): self
    {
        $this->internalDataListUpdate();
        array_push($this->internalDataListData, $object);
        return $this;
    }