/** * Inserts the given UrlWildcard * * @param \eZ\Publish\SPI\Persistence\Content\UrlWildcard $urlWildcard * * @return mixed */ public function insertUrlWildcard(UrlWildcard $urlWildcard) { /** @var $query \ezcQueryInsert */ $query = $this->dbHandler->createInsertQuery(); $query->insertInto($this->dbHandler->quoteTable("ezurlwildcard"))->set($this->dbHandler->quoteColumn("destination_url"), $query->bindValue(trim($urlWildcard->destinationUrl, "/ "), null, \PDO::PARAM_STR))->set($this->dbHandler->quoteColumn("id"), $this->dbHandler->getAutoIncrementValue("ezurlwildcard", "id"))->set($this->dbHandler->quoteColumn("source_url"), $query->bindValue(trim($urlWildcard->sourceUrl, "/ "), null, \PDO::PARAM_STR))->set($this->dbHandler->quoteColumn("type"), $query->bindValue($urlWildcard->forward ? 1 : 2, null, \PDO::PARAM_INT)); $query->prepare()->execute(); return $this->dbHandler->lastInsertId($this->dbHandler->getSequenceName("ezurlwildcard", "id")); }
/** * Inserts a new object state group into database * * @param \eZ\Publish\SPI\Persistence\Content\ObjectState\Group $objectStateGroup */ public function insertObjectStateGroup(Group $objectStateGroup) { $query = $this->dbHandler->createInsertQuery(); $query->insertInto($this->dbHandler->quoteTable('ezcobj_state_group'))->set($this->dbHandler->quoteColumn('id'), $this->dbHandler->getAutoIncrementValue('ezcobj_state_group', 'id'))->set($this->dbHandler->quoteColumn('default_language_id'), $query->bindValue($this->maskGenerator->generateLanguageIndicator($objectStateGroup->defaultLanguage, false), null, \PDO::PARAM_INT))->set($this->dbHandler->quoteColumn('identifier'), $query->bindValue($objectStateGroup->identifier))->set($this->dbHandler->quoteColumn('language_mask'), $query->bindValue($this->generateLanguageMask($objectStateGroup->languageCodes), null, \PDO::PARAM_INT)); $query->prepare()->execute(); $objectStateGroup->id = (int) $this->dbHandler->lastInsertId($this->dbHandler->getSequenceName('ezcobj_state_group', 'id')); $this->insertObjectStateGroupTranslations($objectStateGroup); }
/** * Adds limitations to an existing policy * * @param int $policyId * @param array $limitations * * @return void */ public function addPolicyLimitations($policyId, array $limitations) { foreach ($limitations as $identifier => $values) { $query = $this->handler->createInsertQuery(); $query->insertInto($this->handler->quoteTable('ezpolicy_limitation'))->set($this->handler->quoteColumn('id'), $this->handler->getAutoIncrementValue('ezpolicy_limitation', 'id'))->set($this->handler->quoteColumn('identifier'), $query->bindValue($identifier))->set($this->handler->quoteColumn('policy_id'), $query->bindValue($policyId, null, \PDO::PARAM_INT)); $query->prepare()->execute(); $limitationId = $this->handler->lastInsertId($this->handler->getSequenceName('ezpolicy_limitation', 'id')); foreach ($values as $value) { $query = $this->handler->createInsertQuery(); $query->insertInto($this->handler->quoteTable('ezpolicy_limitation_value'))->set($this->handler->quoteColumn('id'), $this->handler->getAutoIncrementValue('ezpolicy_limitation_value', 'id'))->set($this->handler->quoteColumn('value'), $query->bindValue($value))->set($this->handler->quoteColumn('limitation_id'), $query->bindValue($limitationId, null, \PDO::PARAM_INT)); $query->prepare()->execute(); } } }
/** * Get auto increment value * * Returns the value used for autoincrement tables. Usually this will just * be null. In case for sequence based RDBMS this method can return a * proper value for the given column. * * @param string $table * @param string $column * * @return mixed */ public function getAutoIncrementValue($table, $column) { if ($table === "ezcontentobject_attribute" && $column === "id") { // This is a @HACK -- since this table has a multi-column key with // auto-increment, which is not easy to simulate in SQLite. This // solves it for now. $q = $this->ezcDbHandler->createSelectQuery(); $q->select($q->expr->max("id"))->from("ezcontentobject_attribute"); $statement = $q->prepare(); $statement->execute(); $this->lastInsertedIds["ezcontentobject_attribute.id"] = (int) $statement->fetchColumn() + 1; return $this->lastInsertedIds["ezcontentobject_attribute.id"]; } if ($table === "ezcontentclass" && $column === "id") { // This is a @HACK -- since this table has a multi-column key with // auto-increment, which is not easy to simulate in SQLite. This // solves it for now. $q = $this->ezcDbHandler->createSelectQuery(); $q->select($q->expr->max("id"))->from("ezcontentclass"); $statement = $q->prepare(); $statement->execute(); $this->lastInsertedIds["ezcontentclass.id"] = (int) $statement->fetchColumn() + 1; return $this->lastInsertedIds["ezcontentclass.id"]; } if ($table === "ezcontentclass_attribute" && $column === "id") { // This is a @HACK -- since this table has a multi-column key with // auto-increment, which is not easy to simulate in SQLite. This // solves it for now. $q = $this->ezcDbHandler->createSelectQuery(); $q->select($q->expr->max("id"))->from("ezcontentclass_attribute"); $statement = $q->prepare(); $statement->execute(); $this->lastInsertedIds["ezcontentclass_attribute.id"] = (int) $statement->fetchColumn() + 1; return $this->lastInsertedIds["ezcontentclass_attribute.id"]; } return parent::getAutoIncrementValue($table, $column); }