當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。