Fire/Sql/Collection.php
private function _writeObjectToDb($object, $id)
    {
        $objectId = (!is_null($id)) ? $id : $this->_generateUniqueId();
        $origin = $this->_getObjectOrigin($objectId);
        $object = json_decode(json_encode($object));
        $object->__id = $objectId;
        $object->__revision = $this->_generateRevisionNumber();
        $object->__updated = $this->_generateTimestamp();
        $object->__origin = ($origin) ? $origin : $object->__updated;

        //insert into database
        $insert = Statement::get(
            'INSERT_OBJECT',
            [
                '@collection' => $this->_name,
                '@id' => $this->_connector->quote($object->__id),
                '@revision' => $this->_connector->quote($object->__revision),
                '@committed' => $this->_connector->quote(0),
                '@updated' => $this->_connector->quote($object->__updated),
                '@origin' => $this->_connector->quote($object->__origin),
                '@obj' => $this->_connector->quote(json_encode($object))
            ]
        );
        $this->_connector->exec($insert);
        return $object;
    }
private function _writeObjectToDb($object, $id)
    {
        $objectId = (!is_null($id)) ? $id : $this->_generateUniqueId();
        $origin = $this->_getObjectOrigin($objectId);
        $object = json_decode(json_encode($object));
        $object->__id = $objectId;
        $object->__revision = $this->_generateRevisionNumber();
        $object->__updated = $this->_generateTimestamp();
        $object->__origin = ($origin) ? $origin : $object->__updated;

        //insert into database
        $insert = Statement::get(
            'INSERT_OBJECT',
            [
                '@collection' => $this->_name,
                '@id' => $this->_connector->quote($object->__id),
                '@revision' => $this->_connector->quote($object->__revision),
                '@committed' => $this->_connector->quote(0),
                '@updated' => $this->_connector->quote($object->__updated),
                '@origin' => $this->_connector->quote($object->__origin),
                '@obj' => $this->_connector->quote(json_encode($object))
            ]
        );
        $this->_connector->exec($insert);
        return $object;
    }
private function _writeObjectToDb ( $ object , $ id ) { $ objectId = ( ! is_null ( $ id ) ) ? $ id : $ this -> _generateUniqueId ( ) ; $ origin = $ this -> _getObjectOrigin ( $ objectId ) ; $ object = json_decode ( json_encode ( $ object ) ) ; $ object -> __id = $ objectId ; $ object -> __revision = $ this -> _generateRevisionNumber ( ) ; $ object -> __updated = $ this -> _generateTimestamp ( ) ; $ object -> __origin = ( $ origin ) ? $ origin : $ object -> __updated ; //insert into database $ insert = Statement :: get ( 'INSERT_OBJECT' , [ '@collection' => $ this -> _name , '@id' => $ this -> _connector -> quote ( $ object -> __id ) , '@revision' => $ this -> _connector -> quote ( $ object -> __revision ) , '@committed' => $ this -> _connector -> quote ( 0 ) , '@updated' => $ this -> _connector -> quote ( $ object -> __updated ) , '@origin' => $ this -> _connector -> quote ( $ object -> __origin ) , '@obj' => $ this -> _connector -> quote ( json_encode ( $ object ) ) ] ) ; $ this -> _connector -> exec ( $ insert ) ; return $ object ; }
Part of the upsert process, this method contains logic to write an object
to the database. This method will also add the appropriate meta data to the object
and return it.
@param object $object
@param string $id
@return object
Part of the upsert process this method contains logic to write an object to the database . This method will also add the appropriate meta data to the object and return it .