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


PHP Doctrine_Table::getDefinitionOf方法代码示例

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


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

示例1: buildForeignKeys

 /**
  * Generates foreign keys for the plugin table based on the owner table.
  * These columns are automatically added to the generated model so we can
  * create foreign keys back to the table object that owns the plugin.
  *
  * @param Doctrine_Table $table     the table object that owns the plugin
  * @return array                    an array of foreign key definitions
  */
 public function buildForeignKeys(Doctrine_Table $table)
 {
     $fk = array();
     foreach ((array) $table->getIdentifier() as $column) {
         $def = $table->getDefinitionOf($column);
         unset($def['autoincrement']);
         unset($def['sequence']);
         unset($def['primary']);
         $col = $column;
         $def['primary'] = true;
         $fk[$col] = $def;
     }
     return $fk;
 }
开发者ID:densem-2013,项目名称:exikom,代码行数:22,代码来源:Generator.php

示例2: __construct

 public function __construct($name, Doctrine_Table $table)
 {
     $this->name = $name;
     $this->table = $table;
     $this->definition = $table->getDefinitionOf($name);
 }
开发者ID:xfifix,项目名称:symfony-1.4,代码行数:6,代码来源:sfDoctrineColumn.class.php

示例3: modifyOrderByColumn

 /**
  * Order and Group By are not possible on columns from type text.
  * This method fix this issue by wrap the given term (column) into a CAST directive. 
  * 
  * @see DC-828
  * @param Doctrine_Table $table
  * @param string $field
  * @param string $term The term which will changed if it's necessary, depending to the field type. 
  * @return string
  */
 public function modifyOrderByColumn(Doctrine_Table $table, $field, $term)
 {
     $def = $table->getDefinitionOf($field);
     if ($def['type'] == 'string' && $def['length'] === NULL) {
         $term = 'CAST(' . $term . ' AS varchar(8000))';
     }
     return $term;
 }
开发者ID:cuongnv540,项目名称:jobeet,代码行数:18,代码来源:Mssql.php

示例4: completeDefinition

 /**
  * Completes the given definition
  *
  * @param array $def    definition array to be completed
  * @return array        completed definition array
  */
 public function completeDefinition($def)
 {
     $conn = $this->_table->getConnection();
     $def['table'] = $conn->getTable($def['class']);
     $foreignClasses = array_merge($def['table']->getOption('parents'), array($def['class']));
     $localClasses = array_merge($this->_table->getOption('parents'), array($this->_table->getComponentName()));
     if (isset($def['local'])) {
         if (!isset($def['foreign'])) {
             // local key is set, but foreign key is not
             // try to guess the foreign key
             if ($def['local'] === $this->_table->getIdentifier()) {
                 $def['foreign'] = $this->guessColumns($localClasses, $def['table']);
             } else {
                 // the foreign field is likely to be the
                 // identifier of the foreign class
                 $def['foreign'] = $def['table']->getIdentifier();
                 $def['localKey'] = true;
             }
         } else {
             if ($def['local'] !== $this->_table->getIdentifier()) {
                 $def['localKey'] = true;
             }
         }
     } else {
         if (isset($def['foreign'])) {
             // local key not set, but foreign key is set
             // try to guess the local key
             if ($def['foreign'] === $def['table']->getIdentifier()) {
                 $def['localKey'] = true;
                 try {
                     $def['local'] = $this->guessColumns($foreignClasses, $this->_table);
                 } catch (Doctrine_Relation_Exception $e) {
                     $def['local'] = $this->_table->getIdentifier();
                 }
             } else {
                 $def['local'] = $this->_table->getIdentifier();
             }
         } 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);
                 $column = strtolower($table->getComponentName()) . '_' . $table->getIdentifier();
                 foreach ($foreignClasses as $class2) {
                     $table2 = $conn->getTable($class2);
                     if ($table2->hasColumn($column)) {
                         $def['foreign'] = $column;
                         $def['local'] = $table->getIdentifier();
                         return $def;
                     }
                 }
             }
             foreach ($foreignClasses as $class) {
                 $table = $conn->getTable($class);
                 $column = strtolower($table->getComponentName()) . '_' . $table->getIdentifier();
                 foreach ($localClasses as $class2) {
                     $table2 = $conn->getTable($class2);
                     if ($table2->hasColumn($column)) {
                         $def['foreign'] = $table->getIdentifier();
                         $def['local'] = $column;
                         $def['localKey'] = true;
                         return $def;
                     }
                 }
             }
             // auto-add columns and auto-build relation
             $columns = array();
             foreach ((array) $this->_table->getIdentifier() as $id) {
                 $column = strtolower($table->getComponentName()) . '_' . $id;
                 $col = $this->_table->getDefinitionOf($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'] = $this->_table->getIdentifier();
         }
     }
     return $def;
 }
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:98,代码来源:Parser.php


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