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


PHP Doctrine_Table::getColumnDefinition方法代码示例

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


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

示例1: getManyRelations

 /**
  * Return relations as an array
  *
  * Array must contain 'type' for relation type, 'id' for the name
  * of the PK column of the related table, 'model' for the related class
  * name, 'notnull' for nullability. 'local' for the name of the local column
  * Key must be the alias of the relation column
  *
  * @return array
  */
 public function getManyRelations()
 {
     $rels = $this->_table->getRelations();
     $relations = array();
     foreach ($rels as $rel) {
         $relation = array();
         if ($rel->getType() == Doctrine_Relation::MANY && isset($rel['refTable'])) {
             $relation['id'] = $rel->getTable()->getIdentifier();
             $relation['model'] = $rel->getClass();
             $relation['local'] = $rel->getLocal();
             $definition = $this->_table->getColumnDefinition($rel->getLocal());
             $relation['notnull'] = isset($definition['notnull']) ? $definition['notnull'] : false;
             $relations[$rel->getAlias()] = $relation;
         }
     }
     return $relations;
 }
开发者ID:lciolecki,项目名称:zf-doctrine,代码行数:27,代码来源:Doctrine.php

示例2: getColumnDefinition

 /**
  * Retrieves a column definition from this table schema.
  *
  * @param string $columnName
  * @return array              column definition; @see $_columns
  */
 public function getColumnDefinition($columnName)
 {
     $columnDefinition = parent::getColumnDefinition($columnName);
     if (!$columnDefinition && $this->hasI18n()) {
         $columnDefinition = $this->getI18nTable()->getColumnDefinition($columnName);
     }
     return $columnDefinition;
 }
开发者ID:Regmaya,项目名称:diem,代码行数:14,代码来源:dmDoctrineTable.php

示例3: completeDefinition


//.........这里部分代码省略.........
                 $def['foreign'] = $this->guessColumns($localClasses, $def['table']);
             } else {
                 // the foreign field is likely to be the
                 // identifier of the foreign class
                 $def['foreign'] = $foreignIdColumnName;
                 $def['localKey'] = true;
             }
         } else {
             $def['foreign'] = $def['table']->getColumnName($def['foreign']);
             if ($localIdentifierCount == 1) {
                 if ($def['local'] == $localIdColumnName && isset($def['owningSide']) && $def['owningSide'] === true) {
                     $def['localKey'] = true;
                 } else {
                     if ($def['local'] !== $localIdColumnName && $def['type'] == Doctrine_Relation::ONE) {
                         $def['localKey'] = true;
                     }
                 }
             } else {
                 if ($localIdentifierCount > 1 && !isset($def['localKey'])) {
                     // It's a composite key and since 'foreign' can not point to a composite
                     // key currently, we know that 'local' must be the foreign key.
                     $def['localKey'] = true;
                 }
             }
         }
     } else {
         if (isset($def['foreign'])) {
             $def['foreign'] = $def['table']->getColumnName($def['foreign']);
             // local key not set, but foreign key is set
             // try to guess the local key
             if ($def['foreign'] === $foreignIdColumnName) {
                 $def['localKey'] = true;
                 try {
                     $def['local'] = $this->guessColumns($foreignClasses, $this->_table);
                 } catch (Doctrine_Relation_Exception $e) {
                     $def['local'] = $localIdColumnName;
                 }
             } else {
                 $def['local'] = $localIdColumnName;
             }
         } else {
             // neither local or foreign key is being set
             // try to guess both keys
             $conn = $this->_table->getConnection();
             // the following loops are needed for covering inheritance
             foreach ($localClasses as $class) {
                 $table = $conn->getTable($class);
                 $identifierColumnNames = $table->getIdentifierColumnNames();
                 $idColumnName = array_pop($identifierColumnNames);
                 $column = strtolower($table->getComponentName()) . '_' . $idColumnName;
                 foreach ($foreignClasses as $class2) {
                     $table2 = $conn->getTable($class2);
                     if ($table2->hasColumn($column)) {
                         $def['foreign'] = $column;
                         $def['local'] = $idColumnName;
                         return $def;
                     }
                 }
             }
             foreach ($foreignClasses as $class) {
                 $table = $conn->getTable($class);
                 $identifierColumnNames = $table->getIdentifierColumnNames();
                 $idColumnName = array_pop($identifierColumnNames);
                 $column = strtolower($table->getComponentName()) . '_' . $idColumnName;
                 foreach ($localClasses as $class2) {
                     $table2 = $conn->getTable($class2);
                     if ($table2->hasColumn($column)) {
                         $def['foreign'] = $idColumnName;
                         $def['local'] = $column;
                         $def['localKey'] = true;
                         return $def;
                     }
                 }
             }
             // auto-add columns and auto-build relation
             $columns = array();
             foreach ((array) $this->_table->getIdentifierColumnNames() as $id) {
                 // ?? should this not be $this->_table->getComponentName() ??
                 $column = strtolower($table->getComponentName()) . '_' . $id;
                 $col = $this->_table->getColumnDefinition($id);
                 $type = $col['type'];
                 $length = $col['length'];
                 unset($col['type']);
                 unset($col['length']);
                 unset($col['autoincrement']);
                 unset($col['sequence']);
                 unset($col['primary']);
                 $def['table']->setColumn($column, $type, $length, $col);
                 $columns[] = $column;
             }
             if (count($columns) > 1) {
                 $def['foreign'] = $columns;
             } else {
                 $def['foreign'] = $columns[0];
             }
             $def['local'] = $localIdColumnName;
         }
     }
     return $def;
 }
开发者ID:densem-2013,项目名称:exikom,代码行数:101,代码来源:Parser.php


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