当前位置: 首页>>代码示例>>PHP>>正文


PHP ClassMetadata::getQuotedColumnName方法代码示例

本文整理汇总了PHP中Doctrine\ORM\Mapping\ClassMetadata::getQuotedColumnName方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassMetadata::getQuotedColumnName方法的具体用法?PHP ClassMetadata::getQuotedColumnName怎么用?PHP ClassMetadata::getQuotedColumnName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine\ORM\Mapping\ClassMetadata的用法示例。


在下文中一共展示了ClassMetadata::getQuotedColumnName方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _getSelectConditionSQL

 /**
  * Gets the conditional SQL fragment used in the WHERE clause when selecting
  * entities in this persister.
  *
  * Subclasses are supposed to override this method if they intend to change
  * or alter the criteria by which entities are selected.
  *
  * @param array $criteria
  * @param AssociationMapping $assoc
  * @return string
  */
 protected function _getSelectConditionSQL(array $criteria, $assoc = null)
 {
     $conditionSql = '';
     foreach ($criteria as $field => $value) {
         $conditionSql .= $conditionSql ? ' AND ' : '';
         $placeholder = '?';
         if (isset($this->_class->columnNames[$field])) {
             $className = isset($this->_class->fieldMappings[$field]['inherited']) ? $this->_class->fieldMappings[$field]['inherited'] : $this->_class->name;
             $conditionSql .= $this->_getSQLTableAlias($className) . '.' . $this->_class->getQuotedColumnName($field, $this->_platform);
             if (isset($this->_class->fieldMappings[$field]['requireSQLConversion'])) {
                 $type = Type::getType($this->_class->getTypeOfField($field));
                 $placeholder = $type->convertToDatabaseValueSQL($placeholder, $this->_platform);
             }
         } else {
             if (isset($this->_class->associationMappings[$field])) {
                 if (!$this->_class->associationMappings[$field]['isOwningSide']) {
                     throw ORMException::invalidFindByInverseAssociation($this->_class->name, $field);
                 }
                 $className = isset($this->_class->associationMappings[$field]['inherited']) ? $this->_class->associationMappings[$field]['inherited'] : $this->_class->name;
                 $conditionSql .= $this->_getSQLTableAlias($className) . '.' . $this->_class->associationMappings[$field]['joinColumns'][0]['name'];
             } else {
                 if ($assoc !== null && strpos($field, " ") === false && strpos($field, "(") === false) {
                     // very careless developers could potentially open up this normally hidden api for userland attacks,
                     // therefore checking for spaces and function calls which are not allowed.
                     // found a join column condition, not really a "field"
                     $conditionSql .= $field;
                 } else {
                     throw ORMException::unrecognizedField($field);
                 }
             }
         }
         $conditionSql .= is_array($value) ? ' IN (?)' : ($value === null ? ' IS NULL' : ' = ' . $placeholder);
     }
     return $conditionSql;
 }
开发者ID:ncking,项目名称:doctrine2,代码行数:46,代码来源:BasicEntityPersister.php

示例2: _getSelectConditionSQL

 /**
  * Gets the conditional SQL fragment used in the WHERE clause when selecting
  * entities in this persister.
  *
  * Subclasses are supposed to override this method if they intend to change
  * or alter the criteria by which entities are selected.
  *
  * @param array $criteria
  * @param AssociationMapping $assoc
  * @return string
  */
 protected function _getSelectConditionSQL(array $criteria, $assoc = null)
 {
     $conditionSql = '';
     foreach ($criteria as $field => $value) {
         $conditionSql .= $conditionSql ? ' AND ' : '';
         if (isset($this->_class->columnNames[$field])) {
             if (isset($this->_class->fieldMappings[$field]['inherited'])) {
                 $conditionSql .= $this->_getSQLTableAlias($this->_class->fieldMappings[$field]['inherited']) . '.';
             } else {
                 $conditionSql .= $this->_getSQLTableAlias($this->_class->name) . '.';
             }
             $conditionSql .= $this->_class->getQuotedColumnName($field, $this->_platform);
         } else {
             if ($assoc !== null) {
                 if ($assoc['type'] == ClassMetadata::MANY_TO_MANY) {
                     $owningAssoc = $assoc['isOwningSide'] ? $assoc : $this->_em->getClassMetadata($assoc['targetEntity'])->associationMappings[$assoc['mappedBy']];
                     $conditionSql .= $this->_class->getQuotedJoinTableName($owningAssoc, $this->_platform) . '.' . $field;
                 } else {
                     $conditionSql .= $field;
                 }
             } else {
                 throw ORMException::unrecognizedField($field);
             }
         }
         $conditionSql .= ' = ?';
     }
     return $conditionSql;
 }
开发者ID:skoop,项目名称:symfony-sandbox,代码行数:39,代码来源:BasicEntityPersister.php

示例3: addFilterConstraint

 /**
  * {@inheritdoc}
  */
 public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias)
 {
     $className = $targetEntity->getName();
     if (isset(self::$disabled[$className])) {
         return '';
     } elseif (array_key_exists($targetEntity->rootEntityName, self::$disabled)) {
         return '';
     }
     $dataKey = $className . '|' . $targetTableAlias;
     if (!isset(self::$data[$dataKey])) {
         $annotation = $this->getReflectionService()->getClassAnnotation($className, SoftDeletable::class);
         if ($annotation !== null) {
             $existingProperties = $this->getReflectionService()->getClassPropertyNames($className);
             if (!in_array($annotation->deleteProperty, $existingProperties)) {
                 throw new PropertyNotFoundException("Property '" . $annotation->deleteProperty . "' not found for '" . $className . "'", 1439207432);
             }
             $conn = $this->getEntityManager()->getConnection();
             $platform = $conn->getDatabasePlatform();
             $column = $targetEntity->getQuotedColumnName($annotation->deleteProperty, $platform);
             $addCondSql = $platform->getIsNullExpression($targetTableAlias . '.' . $column);
             if ($annotation->timeAware) {
                 $addCondSql .= ' OR ' . $targetTableAlias . '.' . $column . ' > ' . $conn->quote(date('Y-m-d H:i:s'));
             }
             self::$data[$dataKey] = $addCondSql;
         } else {
             self::$data[$dataKey] = false;
         }
     }
     return self::$data[$dataKey] ? self::$data[$dataKey] : '';
 }
开发者ID:sixty-nine,项目名称:CDSRC.Libraries,代码行数:33,代码来源:MarkedAsDeletedFilter.php

示例4: _getSelectColumnSQL

 /**
  * {@inheritdoc}
  */
 protected function _getSelectColumnSQL($field, ClassMetadata $class, $alias = 'r')
 {
     $columnName = $class->columnNames[$field];
     $sql = $this->_getSQLTableAlias($class->name, $alias == 'r' ? '' : $alias) . '.' . $class->getQuotedColumnName($field, $this->_platform);
     $columnAlias = $this->_platform->getSQLResultCasing($columnName . $this->_sqlAliasCounter++);
     $this->_rsm->addFieldResult($alias, $columnAlias, $field, $class->name);
     return $sql . ' AS ' . $columnAlias;
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:11,代码来源:AbstractEntityInheritancePersister.php

示例5: _getSelectColumnSQL

 /**
  * {@inheritdoc}
  */
 protected function _getSelectColumnSQL($field, ClassMetadata $class)
 {
     $columnName = $class->columnNames[$field];
     $sql = $this->_getSQLTableAlias($class->name) . '.' . $class->getQuotedColumnName($field, $this->_platform);
     $columnAlias = $this->_platform->getSQLResultCasing($columnName . $this->_sqlAliasCounter++);
     if (!isset($this->_resultColumnNames[$columnAlias])) {
         $this->_resultColumnNames[$columnAlias] = $columnName;
         $this->_declaringClassMap[$columnAlias] = $class;
     }
     return "{$sql} AS {$columnAlias}";
 }
开发者ID:EstebanFuentealba,项目名称:PHPCodeCreator,代码行数:14,代码来源:AbstractEntityInheritancePersister.php

示例6: _getSelectColumnSQL

 /**
  * {@inheritdoc}
  */
 protected function _getSelectColumnSQL($field, ClassMetadata $class, $alias = 'r')
 {
     $columnName = $class->columnNames[$field];
     $sql = $this->_getSQLTableAlias($class->name, $alias == 'r' ? '' : $alias) . '.' . $class->getQuotedColumnName($field, $this->_platform);
     $columnAlias = $this->getSQLColumnAlias($columnName);
     $this->_rsm->addFieldResult($alias, $columnAlias, $field, $class->name);
     if (isset($class->fieldMappings[$field]['requireSQLConversion'])) {
         $type = Type::getType($class->getTypeOfField($field));
         $sql = $type->convertToPHPValueSQL($sql, $this->_platform);
     }
     return $sql . ' AS ' . $columnAlias;
 }
开发者ID:pabloasc,项目名称:test_social,代码行数:15,代码来源:AbstractEntityInheritancePersister.php

示例7: _generateInsertSQL

 /**
  * Generates the INSERT SQL used by the persister to persist entities.
  * 
  * @return string
  * @internal Result is cached by getInsertSQL() per request.
  */
 protected function _generateInsertSQL()
 {
     $insertSql = '';
     $columns = $this->_getInsertColumnList();
     if (empty($columns)) {
         $insertSql = $this->_platform->getEmptyIdentityInsertSQL($this->_class->getQuotedTableName($this->_platform), $this->_class->getQuotedColumnName($this->_class->identifier[0], $this->_platform));
     } else {
         $columns = array_unique($columns);
         $values = array_fill(0, count($columns), '?');
         $insertSql = 'INSERT INTO ' . $this->_class->getQuotedTableName($this->_platform) . ' (' . implode(', ', $columns) . ') ' . 'VALUES (' . implode(', ', $values) . ')';
     }
     return $insertSql;
 }
开发者ID:poulikov,项目名称:readlater,代码行数:19,代码来源:StandardEntityPersister.php

示例8: _getSelectConditionSQL

 /**
  * Gets the conditional SQL fragment used in the WHERE clause when selecting
  * entities in this persister.
  *
  * Subclasses are supposed to override this method if they intend to change
  * or alter the criteria by which entities are selected.
  *
  * @param array $criteria
  * @param AssociationMapping $assoc
  * @return string
  */
 protected function _getSelectConditionSQL(array $criteria, $assoc = null)
 {
     $conditionSql = '';
     foreach ($criteria as $field => $value) {
         $conditionSql .= $conditionSql ? ' AND ' : '';
         if (isset($this->_class->columnNames[$field])) {
             if (isset($this->_class->fieldMappings[$field]['inherited'])) {
                 $conditionSql .= $this->_getSQLTableAlias($this->_class->fieldMappings[$field]['inherited']) . '.';
             } else {
                 $conditionSql .= $this->_getSQLTableAlias($this->_class->name) . '.';
             }
             $conditionSql .= $this->_class->getQuotedColumnName($field, $this->_platform);
         } else {
             if (isset($this->_class->associationMappings[$field])) {
                 if (!$this->_class->associationMappings[$field]['isOwningSide']) {
                     throw ORMException::invalidFindByInverseAssociation($this->_class->name, $field);
                 }
                 if (isset($this->_class->associationMappings[$field]['inherited'])) {
                     $conditionSql .= $this->_getSQLTableAlias($this->_class->associationMappings[$field]['inherited']) . '.';
                 } else {
                     $conditionSql .= $this->_getSQLTableAlias($this->_class->name) . '.';
                 }
                 // only apply fix for *-to-many associations, since *-to-one
                 // associations don't use joinTable
                 if (isset($this->_class->associationMappings[$field]['joinTable'])) {
                     // bugfix http://www.doctrine-project.org/jira/browse/DDC-2808
                     $conditionSql .= $this->_class->associationMappings[$field]['joinTable']['joinColumns'][0]['name'];
                 } else {
                     $conditionSql .= $this->_class->associationMappings[$field]['joinColumns'][0]['name'];
                 }
             } else {
                 if ($assoc !== null && strpos($field, " ") === false && strpos($field, "(") === false) {
                     // very careless developers could potentially open up this normally hidden api for userland attacks,
                     // therefore checking for spaces and function calls which are not allowed.
                     // found a join column condition, not really a "field"
                     $conditionSql .= $field;
                 } else {
                     throw ORMException::unrecognizedField($field);
                 }
             }
         }
         $conditionSql .= $value === null ? ' IS NULL' : ' = ?';
     }
     return $conditionSql;
 }
开发者ID:Cloudrexx,项目名称:cloudrexx,代码行数:56,代码来源:BasicEntityPersister.php

示例9: getInsertRevisionSQL

 /**
  * @param ClassMetadata $class
  * @return string
  * @throws \Doctrine\DBAL\DBALException
  */
 private function getInsertRevisionSQL($class)
 {
     if (!isset($this->insertRevisionSQL[$class->name])) {
         $placeholders = array('?', '?');
         $tableName = $this->config->getTablePrefix() . $class->table['name'] . $this->config->getTableSuffix();
         $sql = "INSERT INTO " . $tableName . " (" . $this->config->getRevisionFieldName() . ", " . $this->config->getRevisionTypeFieldName();
         $fields = array();
         foreach ($class->associationMappings as $field => $assoc) {
             if ($class->isInheritanceTypeJoined() && $class->isInheritedAssociation($field)) {
                 continue;
             }
             if (($assoc['type'] & ClassMetadata::TO_ONE) > 0 && $assoc['isOwningSide']) {
                 foreach ($assoc['targetToSourceKeyColumns'] as $sourceCol) {
                     $fields[$sourceCol] = true;
                     $sql .= ', ' . $sourceCol;
                     $placeholders[] = '?';
                 }
             }
         }
         foreach ($class->fieldNames as $field) {
             if (array_key_exists($field, $fields)) {
                 continue;
             }
             if ($class->isInheritanceTypeJoined() && $class->isInheritedField($field) && !$class->isIdentifier($field)) {
                 continue;
             }
             $type = Type::getType($class->fieldMappings[$field]['type']);
             $placeholders[] = !empty($class->fieldMappings[$field]['requireSQLConversion']) ? $type->convertToDatabaseValueSQL('?', $this->platform) : '?';
             $sql .= ', ' . $class->getQuotedColumnName($field, $this->platform);
         }
         if ($class->isInheritanceTypeJoined() && $class->rootEntityName == $class->name || $class->isInheritanceTypeSingleTable()) {
             $sql .= ', ' . $class->discriminatorColumn['name'];
             $placeholders[] = '?';
         }
         $sql .= ") VALUES (" . implode(", ", $placeholders) . ")";
         $this->insertRevisionSQL[$class->name] = $sql;
     }
     return $this->insertRevisionSQL[$class->name];
 }
开发者ID:hayloft,项目名称:EntityAudit,代码行数:44,代码来源:LogRevisionsListener.php

示例10: _generateClassTableInheritanceJoins

 /**
  * Generates the SQL JOINs that are necessary for Class Table Inheritance
  * for the given class.
  *
  * @param ClassMetadata $class The class for which to generate the joins.
  * @param string $dqlAlias The DQL alias of the class.
  * @return string The SQL.
  */
 private function _generateClassTableInheritanceJoins($class, $dqlAlias)
 {
     $sql = '';
     $baseTableAlias = $this->getSQLTableAlias($class->table['name'], $dqlAlias);
     // INNER JOIN parent class tables
     foreach ($class->parentClasses as $parentClassName) {
         $parentClass = $this->_em->getClassMetadata($parentClassName);
         $tableAlias = $this->getSQLTableAlias($parentClass->table['name'], $dqlAlias);
         // If this is a joined association we must use left joins to preserve the correct result.
         $sql .= isset($this->_queryComponents[$dqlAlias]['relation']) ? ' LEFT ' : ' INNER ';
         $sql .= 'JOIN ' . $parentClass->getQuotedTableName($this->_platform) . ' ' . $tableAlias . ' ON ';
         $first = true;
         foreach ($class->identifier as $idField) {
             if ($first) {
                 $first = false;
             } else {
                 $sql .= ' AND ';
             }
             $columnName = $class->getQuotedColumnName($idField, $this->_platform);
             $sql .= $baseTableAlias . '.' . $columnName . ' = ' . $tableAlias . '.' . $columnName;
         }
     }
     // LEFT JOIN subclass tables, if partial objects disallowed.
     if (!$this->_query->getHint(Query::HINT_FORCE_PARTIAL_LOAD)) {
         foreach ($class->subClasses as $subClassName) {
             $subClass = $this->_em->getClassMetadata($subClassName);
             $tableAlias = $this->getSQLTableAlias($subClass->table['name'], $dqlAlias);
             $sql .= ' LEFT JOIN ' . $subClass->getQuotedTableName($this->_platform) . ' ' . $tableAlias . ' ON ';
             $first = true;
             foreach ($class->identifier as $idField) {
                 if ($first) {
                     $first = false;
                 } else {
                     $sql .= ' AND ';
                 }
                 $columnName = $class->getQuotedColumnName($idField, $this->_platform);
                 $sql .= $baseTableAlias . '.' . $columnName . ' = ' . $tableAlias . '.' . $columnName;
             }
         }
     }
     return $sql;
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:50,代码来源:SqlWalker.php

示例11: _gatherColumn

 /**
  * Creates a column definition as required by the DBAL from an ORM field mapping definition.
  *
  * @param ClassMetadata $class The class that owns the field mapping.
  * @param array $mapping The field mapping.
  * @param Table $table
  * @return array The portable column definition as required by the DBAL.
  */
 private function _gatherColumn($class, array $mapping, $table)
 {
     $columnName = $class->getQuotedColumnName($mapping['fieldName'], $this->_platform);
     $columnType = $mapping['type'];
     $options = array();
     $options['length'] = isset($mapping['length']) ? $mapping['length'] : null;
     $options['notnull'] = isset($mapping['nullable']) ? !$mapping['nullable'] : true;
     if ($class->isInheritanceTypeSingleTable() && count($class->parentClasses) > 0) {
         $options['notnull'] = false;
     }
     $options['platformOptions'] = array();
     $options['platformOptions']['version'] = $class->isVersioned && $class->versionField == $mapping['fieldName'] ? true : false;
     if (strtolower($columnType) == 'string' && $options['length'] === null) {
         $options['length'] = 255;
     }
     if (isset($mapping['precision'])) {
         $options['precision'] = $mapping['precision'];
     }
     if (isset($mapping['scale'])) {
         $options['scale'] = $mapping['scale'];
     }
     if (isset($mapping['default'])) {
         $options['default'] = $mapping['default'];
     }
     if (isset($mapping['columnDefinition'])) {
         $options['columnDefinition'] = $mapping['columnDefinition'];
     }
     if ($class->isIdGeneratorIdentity() && $class->getIdentifierFieldNames() == array($mapping['fieldName'])) {
         $options['autoincrement'] = true;
     }
     if ($class->isInheritanceTypeJoined() && $class->name != $class->rootEntityName) {
         $options['autoincrement'] = false;
     }
     if ($table->hasColumn($columnName)) {
         // required in some inheritance scenarios
         $table->changeColumn($columnName, $options);
     } else {
         $table->addColumn($columnName, $columnType, $options);
     }
     $isUnique = isset($mapping['unique']) ? $mapping['unique'] : false;
     if ($isUnique) {
         $table->addUniqueIndex(array($columnName));
     }
 }
开发者ID:jackbravo,项目名称:symfony-sandbox,代码行数:52,代码来源:SchemaTool.php


注:本文中的Doctrine\ORM\Mapping\ClassMetadata::getQuotedColumnName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。