quoteIdentifier() public method

Ignores some properties of identifier quoting, but since we use somehow sane table and column names, ourselves, this is fine. This is an optimization and works around the ezcDB implementation.
public quoteIdentifier ( string $identifier ) : string
$identifier string
return string
 function convertFields(OutputInterface $output)
 {
     $query = $this->db->createSelectQuery();
     $query->select($query->expr->count('*'));
     $query->from('ezcontentobject_attribute');
     $query->where($query->expr->eq($this->db->quoteIdentifier('data_type_string'), $query->bindValue('ezxmltext', null, PDO::PARAM_STR)));
     $statement = $query->prepare();
     $statement->execute();
     $count = $statement->fetchColumn();
     $output->writeln("Found {$count} field rows to convert.");
     $query = $this->db->createSelectQuery();
     $query->select('*');
     $query->from('ezcontentobject_attribute');
     $query->where($query->expr->eq($this->db->quoteIdentifier('data_type_string'), $query->bindValue('ezxmltext', null, PDO::PARAM_STR)));
     $statement = $query->prepare();
     $statement->execute();
     while ($row = $statement->fetch(PDO::FETCH_ASSOC)) {
         if (empty($row['data_text'])) {
             $inputValue = Value::EMPTY_VALUE;
         } else {
             $inputValue = $row['data_text'];
         }
         $converted = $this->convert($inputValue);
         $updateQuery = $this->db->createUpdateQuery();
         $updateQuery->update($this->db->quoteIdentifier('ezcontentobject_attribute'));
         $updateQuery->set($this->db->quoteIdentifier('data_type_string'), $updateQuery->bindValue('ezrichtext', null, PDO::PARAM_STR));
         $updateQuery->set($this->db->quoteIdentifier('data_text'), $updateQuery->bindValue($converted, null, PDO::PARAM_STR));
         $updateQuery->where($updateQuery->expr->lAnd($updateQuery->expr->eq($this->db->quoteIdentifier('id'), $updateQuery->bindValue($row['id'], null, PDO::PARAM_INT)), $updateQuery->expr->eq($this->db->quoteIdentifier('version'), $updateQuery->bindValue($row['version'], null, PDO::PARAM_INT))));
         $updateQuery->prepare()->execute();
         $this->logger->info("Converted ezxmltext field #{$row['id']} to richtext", ['original' => $inputValue, 'converted' => $converted]);
     }
     $output->writeln("Converted {$count} ezxmltext fields to richtext");
 }
 /**
  * Returns searchable field mapping data
  *
  * @return array
  */
 public function getSearchableFieldMapData()
 {
     $query = $this->dbHandler->createSelectQuery();
     $query->select($this->dbHandler->alias($this->dbHandler->quoteColumn("identifier", "ezcontentclass_attribute"), $this->dbHandler->quoteIdentifier("field_definition_identifier")), $this->dbHandler->alias($this->dbHandler->quoteColumn("identifier", "ezcontentclass"), $this->dbHandler->quoteIdentifier("content_type_identifier")), $this->dbHandler->alias($this->dbHandler->quoteColumn("id", "ezcontentclass_attribute"), $this->dbHandler->quoteIdentifier("field_definition_id")), $this->dbHandler->alias($this->dbHandler->quoteColumn("data_type_string", "ezcontentclass_attribute"), $this->dbHandler->quoteIdentifier("field_type_identifier")))->from($this->dbHandler->quoteTable("ezcontentclass_attribute"))->innerJoin($this->dbHandler->quoteTable("ezcontentclass"), $query->expr->eq($this->dbHandler->quoteColumn("contentclass_id", "ezcontentclass_attribute"), $this->dbHandler->quoteColumn("id", "ezcontentclass")))->where($query->expr->eq($this->dbHandler->quoteColumn("is_searchable", "ezcontentclass_attribute"), $query->bindValue(1, null, PDO::PARAM_INT)));
     $statement = $query->prepare($query);
     $statement->execute();
     return $statement->fetchAll(\PDO::FETCH_ASSOC);
 }
    /**
     * Get sorted arrays of content IDs, which should be returned
     *
     * @param Criterion $filter
     * @param array $sort
     * @param mixed $offset
     * @param mixed $limit
     * @param mixed $translations
     *
     * @return int[]
     */
    protected function getContentInfoList( Criterion $filter, $sort, $offset, $limit, $translations )
    {
        $query = $this->handler->createSelectQuery();
        $query->selectDistinct(
            'ezcontentobject.*',
            $this->handler->aliasedColumn( $query, 'main_node_id', 'main_tree' )
        );

        if ( $sort !== null )
        {
            $this->sortClauseConverter->applySelect( $query, $sort );
        }

        $query->from(
            $this->handler->quoteTable( 'ezcontentobject' )
        )->innerJoin(
            'ezcontentobject_version',
            'ezcontentobject.id',
            'ezcontentobject_version.contentobject_id'
        )->leftJoin(
            $this->handler->alias(
                $this->handler->quoteTable( 'ezcontentobject_tree' ),
                $this->handler->quoteIdentifier( 'main_tree' )
            ),
            $query->expr->lAnd(
                $query->expr->eq(
                    $this->handler->quoteColumn( "contentobject_id", "main_tree" ),
                    $this->handler->quoteColumn( "id", "ezcontentobject" )
                ),
                $query->expr->eq(
                    $this->handler->quoteColumn( "main_node_id", "main_tree" ),
                    $this->handler->quoteColumn( "node_id", "main_tree" )
                )
            )
        );

        if ( $sort !== null )
        {
            $this->sortClauseConverter->applyJoin( $query, $sort );
        }

        $query->where(
            $this->getQueryCondition( $filter, $query, $translations )
        );

        if ( $sort !== null )
        {
            $this->sortClauseConverter->applyOrderBy( $query );
        }

        $query->limit( $limit, $offset );

        $statement = $query->prepare();
        $statement->execute();

        return $statement->fetchAll( \PDO::FETCH_ASSOC );
    }
 /**
  * Returns field mapping data
  *
  * Returns an associative array with ContentType and FieldDefinition identifiers as
  * first and second level keys respectively, and FieldDefinition ID as value.
  *
  * @return array
  */
 public function getFieldMap()
 {
     $query = $this->dbHandler->createSelectQuery();
     $query->select($this->dbHandler->alias($this->dbHandler->quoteColumn("id", "ezcontentclass_attribute"), $this->dbHandler->quoteIdentifier("field_id")), $this->dbHandler->alias($this->dbHandler->quoteColumn("identifier", "ezcontentclass_attribute"), $this->dbHandler->quoteIdentifier("field_identifier")), $this->dbHandler->alias($this->dbHandler->quoteColumn("identifier", "ezcontentclass"), $this->dbHandler->quoteIdentifier("type_identifier")))->from($this->dbHandler->quoteTable("ezcontentclass_attribute"))->innerJoin($this->dbHandler->quoteTable("ezcontentclass"), $query->expr->eq($this->dbHandler->quoteColumn("contentclass_id", "ezcontentclass_attribute"), $this->dbHandler->quoteColumn("id", "ezcontentclass")));
     $statement = $query->prepare($query);
     $statement->execute();
     $map = array();
     $rows = $statement->fetchAll(\PDO::FETCH_ASSOC);
     foreach ($rows as $row) {
         $map[$row["type_identifier"]][$row["field_identifier"]] = $row["field_id"];
     }
     return $map;
 }
 /**
  * Loads all roles associated with the given content objects.
  *
  * @param array $contentIds
  * @param int $status One of Role::STATUS_DEFINED|Role::STATUS_DRAFT
  *
  * @return array
  */
 public function loadRolesForContentObjects($contentIds, $status = Role::STATUS_DEFINED)
 {
     $query = $this->handler->createSelectQuery();
     if ($status === Role::STATUS_DEFINED) {
         $roleIdCondition = $query->expr->eq($this->handler->quoteColumn('id', 'ezrole'), $this->handler->quoteColumn('role_id', 'ezuser_role_search'));
     } else {
         $roleIdCondition = $query->expr->eq($this->handler->quoteColumn('version', 'ezrole'), $this->handler->quoteColumn('role_id', 'ezuser_role_search'));
     }
     $query->select($this->handler->aliasedColumn($query, 'contentobject_id', 'ezuser_role'), $this->handler->aliasedColumn($query, 'id', 'ezrole'), $this->handler->aliasedColumn($query, 'name', 'ezrole'), $this->handler->aliasedColumn($query, 'version', 'ezrole'), $this->handler->aliasedColumn($query, 'id', 'ezpolicy'), $this->handler->aliasedColumn($query, 'function_name', 'ezpolicy'), $this->handler->aliasedColumn($query, 'module_name', 'ezpolicy'), $this->handler->aliasedColumn($query, 'original_id', 'ezpolicy'), $this->handler->aliasedColumn($query, 'identifier', 'ezpolicy_limitation'), $this->handler->aliasedColumn($query, 'value', 'ezpolicy_limitation_value'))->from($query->alias($this->handler->quoteTable('ezuser_role'), $this->handler->quoteIdentifier('ezuser_role_search')))->leftJoin($this->handler->quoteTable('ezrole'), $roleIdCondition)->leftJoin($this->handler->quoteTable('ezuser_role'), $query->expr->eq($this->handler->quoteColumn('role_id', 'ezuser_role'), $this->handler->quoteColumn('id', 'ezrole')))->leftJoin($this->handler->quoteTable('ezpolicy'), $query->expr->eq($this->handler->quoteColumn('role_id', 'ezpolicy'), $this->handler->quoteColumn('id', 'ezrole')))->leftJoin($this->handler->quoteTable('ezpolicy_limitation'), $query->expr->eq($this->handler->quoteColumn('policy_id', 'ezpolicy_limitation'), $this->handler->quoteColumn('id', 'ezpolicy')))->leftJoin($this->handler->quoteTable('ezpolicy_limitation_value'), $query->expr->eq($this->handler->quoteColumn('limitation_id', 'ezpolicy_limitation_value'), $this->handler->quoteColumn('id', 'ezpolicy_limitation')))->where($query->expr->in($this->handler->quoteColumn('contentobject_id', 'ezuser_role_search'), $contentIds));
     $statement = $query->prepare();
     $statement->execute();
     return $statement->fetchAll(\PDO::FETCH_ASSOC);
 }
Exemplo n.º 6
0
 /**
  * Returns the quoted sort column name.
  *
  * @param int $number
  *
  * @return string
  */
 protected function getSortColumnName($number)
 {
     return $this->dbHandler->quoteIdentifier('sort_column_' . $number);
 }