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


PHP Doctrine_Table::getRelations方法代码示例

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


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

示例1: _getRelations

 /**
  * Returns all un-ignored relations
  * @return array
  */
 protected function _getRelations()
 {
     $relations = array();
     foreach ($this->_table->getRelations() as $name => $definition) {
         if (in_array($definition->getLocal(), $this->_ignoreColumns) || $this->_generateManyFields == false && $definition->getType() == Doctrine_Relation::MANY) {
             continue;
         }
         $relations[$name] = $definition;
     }
     return $relations;
 }
开发者ID:abtris,项目名称:zfcore,代码行数:15,代码来源:DoctrineForm.php

示例2: isForeignKey

 /**
  * Returns true if this column is a foreign key and false if it is not
  *
  * @return boolean $isForeignKey
  */
 public function isForeignKey()
 {
     if (isset($this->foreignClassName)) {
         return true;
     }
     if ($this->isPrimaryKey()) {
         return false;
     }
     foreach ($this->table->getRelations() as $relation) {
         if (strtolower($relation['local']) == strtolower($this->name)) {
             $this->foreignClassName = $relation['class'];
             return true;
         }
     }
     return false;
 }
开发者ID:bigcalm,项目名称:urlcatcher,代码行数:21,代码来源:sfDoctrineColumn.class.php

示例3: 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

示例4: isForeignKey

 /**
  * Returns true if this column is a foreign key and false if it is not
  *
  * @return boolean $isForeignKey
  */
 public function isForeignKey()
 {
     if (isset($this->foreignClassName)) {
         return true;
     }
     if ($this->isPrimaryKey()) {
         return false;
     }
     foreach ($this->table->getRelations() as $relation) {
         $local = (array) $relation['local'];
         $local = array_map('strtolower', $local);
         if (in_array(strtolower($this->name), $local)) {
             $this->foreignClassName = $relation['class'];
             return true;
         }
     }
     return false;
 }
开发者ID:xfifix,项目名称:symfony-1.4,代码行数:23,代码来源:sfDoctrineColumn.class.php

示例5: buildIntegrityRelations

    /**
     * buildIntegrityRelations
     *
     * @param Doctrine_Table $table
     * @param mixed $aliases
     * @param mixed $fields
     * @param mixed $indexes
     * @param mixed $components
     * @return void
     */
    public function buildIntegrityRelations(Doctrine_Table $table, &$aliases, &$fields, &$indexes, &$components)
    {
        $deleteActions = Doctrine_Manager::getInstance()
                         ->getDeleteActions($table->getComponentName());

        foreach ($table->getRelations() as $relation) {
            $componentName = $relation->getTable()->getComponentName();
            if (in_array($componentName, $components)) {
                continue;
            }
            $components[] = $componentName;

            $alias = strtolower(substr($relation->getAlias(), 0, 1));

            if ( ! isset($indexes[$alias])) {
                $indexes[$alias] = 1;
            }

            if (isset($deleteActions[$componentName])) {
                if (isset($aliases[$alias])) {
                    $alias = $alias . ++$indexes[$alias];
                }
                $aliases[$alias] = $relation->getAlias();

                if ($deleteActions[$componentName] === 'SET NULL') {
                    if ($relation instanceof Doctrine_Relation_ForeignKey) {
                        foreach ((array) $relation->getForeign() as $foreign) {
                            $fields .= ', ' . $alias . '.' . $foreign;
                        }
                    } elseif ($relation instanceof Doctrine_Relation_LocalKey) {
                        foreach ((array) $relation->getLocal() as $foreign) {
                            $fields .= ', ' . $alias . '.' . $foreign;
                        }
                    }
                }
                foreach ((array) $relation->getTable()->getIdentifier() as $id) {
                    $fields .= ', ' . $alias . '.' . $id;
                }
                if ($deleteActions[$componentName] === 'CASCADE') {
                    $this->buildIntegrityRelations($relation->getTable(), $aliases, $fields, $indexes, $components);
                }
            }
        }
    }
开发者ID:nationalfield,项目名称:symfony,代码行数:54,代码来源:IntegrityMapper.php

示例6: listColumns

 /**
  * Provides a array of columns
  *
  * @param Doctrine_Table $table The current Doctrine_Table
  *
  * @return array
  */
 private function listColumns(Doctrine_Table $table)
 {
     $ret = array();
     foreach ($table->getColumns() as $name => $column) {
         if (empty($column['primary'])) {
             $added = true;
             foreach ($table->getRelations() as $relation) {
                 if ($relation instanceof Doctrine_Relation_LocalKey && $relation->getLocal() === $name) {
                     $added = false;
                     break;
                 }
             }
             if ($added) {
                 $ret[] = sprintf("%s (%s)", $name, $column['type']);
             }
         }
     }
     return $ret;
 }
开发者ID:yuxw75,项目名称:Surrogate,代码行数:26,代码来源:doctrineGraphvizMcdGenerator.class.php


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