/** * Inserts a new relation database record * * @param \eZ\Publish\SPI\Persistence\Content\Relation\CreateStruct $createStruct * * @return int ID the inserted ID */ public function insertRelation(RelationCreateStruct $createStruct) { $q = $this->dbHandler->createInsertQuery(); $q->insertInto($this->dbHandler->quoteTable('ezcontentobject_link'))->set($this->dbHandler->quoteColumn('id'), $this->dbHandler->getAutoIncrementValue('ezcontentobject_link', 'id'))->set($this->dbHandler->quoteColumn('contentclassattribute_id'), $q->bindValue((int) $createStruct->sourceFieldDefinitionId, null, \PDO::PARAM_INT))->set($this->dbHandler->quoteColumn('from_contentobject_id'), $q->bindValue($createStruct->sourceContentId, null, \PDO::PARAM_INT))->set($this->dbHandler->quoteColumn('from_contentobject_version'), $q->bindValue($createStruct->sourceContentVersionNo, null, \PDO::PARAM_INT))->set($this->dbHandler->quoteColumn('relation_type'), $q->bindValue($createStruct->type, null, \PDO::PARAM_INT))->set($this->dbHandler->quoteColumn('to_contentobject_id'), $q->bindValue($createStruct->destinationContentId, null, \PDO::PARAM_INT)); $q->prepare()->execute(); return $this->dbHandler->lastInsertId($this->dbHandler->getSequenceName('ezcontentobject_link', 'id')); }
/** * Create an entry in the node assignment table * * @param \eZ\Publish\SPI\Persistence\Content\Location\CreateStruct $createStruct * @param mixed $parentNodeId * @param int $type * * @return void */ public function createNodeAssignment(CreateStruct $createStruct, $parentNodeId, $type = self::NODE_ASSIGNMENT_OP_CODE_CREATE_NOP) { $isMain = $createStruct->mainLocationId === true ? 1 : 0; $query = $this->handler->createInsertQuery(); $query->insertInto($this->handler->quoteTable('eznode_assignment'))->set($this->handler->quoteColumn('contentobject_id'), $query->bindValue($createStruct->contentId, null, \PDO::PARAM_INT))->set($this->handler->quoteColumn('contentobject_version'), $query->bindValue($createStruct->contentVersion, null, \PDO::PARAM_INT))->set($this->handler->quoteColumn('from_node_id'), $query->bindValue(0, null, \PDO::PARAM_INT))->set($this->handler->quoteColumn('id'), $this->handler->getAutoIncrementValue('eznode_assignment', 'id'))->set($this->handler->quoteColumn('is_main'), $query->bindValue($isMain, null, \PDO::PARAM_INT))->set($this->handler->quoteColumn('op_code'), $query->bindValue($type, null, \PDO::PARAM_INT))->set($this->handler->quoteColumn('parent_node'), $query->bindValue($parentNodeId, null, \PDO::PARAM_INT))->set($this->handler->quoteColumn('parent_remote_id'), $query->bindValue(''))->set($this->handler->quoteColumn('remote_id'), $query->bindValue($createStruct->remoteId, null, \PDO::PARAM_STR))->set($this->handler->quoteColumn('sort_field'), $query->bindValue(Location::SORT_FIELD_PUBLISHED, null, \PDO::PARAM_INT))->set($this->handler->quoteColumn('sort_order'), $query->bindValue(Location::SORT_ORDER_DESC, null, \PDO::PARAM_INT)); $query->prepare()->execute(); }