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


PHP Doctrine_Table::getRelation方法代码示例

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


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

示例1: getRelation

 public function getRelation($alias, $recursive = true)
 {
     if ($this->hasRelation($alias)) {
         return parent::getRelation($alias, $recursive);
     }
     foreach (ExtensionDefinitionTable::$extensionNamesWithFields as $extension) {
         if (Doctrine::getTable($extension)->hasRelation($alias)) {
             return Doctrine::getTable($extension)->getRelation($alias, $recursive);
         }
     }
     return parent::getRelation($alias, $recursive);
 }
开发者ID:silky,项目名称:littlesis,代码行数:12,代码来源:EntityTable.class.php

示例2: populateRelated

    /**
     * Populate the relationship $name for all records in the passed collection
     *
     * @param string $name
     * @param Doctrine_Collection $coll
     * @return void
     */
    public function populateRelated($name, Doctrine_Collection $coll)
    {
        $rel     = $this->_table->getRelation($name);
        $table   = $rel->getTable();
        $foreign = $rel->getForeign();
        $local   = $rel->getLocal();

        if ($rel instanceof Doctrine_Relation_LocalKey) {
            foreach ($this->data as $key => $record) {
                foreach ($coll as $k => $related) {
                    if ($related[$foreign] == $record[$local]) {
                        $this->data[$key]->setRelated($name, $related);
                    }
                }
            }
        } elseif ($rel instanceof Doctrine_Relation_ForeignKey) {
            foreach ($this->data as $key => $record) {
                if ( ! $record->exists()) {
                    continue;
                }
                $sub = Doctrine_Collection::create($table);

                foreach ($coll as $k => $related) {
                    if ($related[$foreign] == $record[$local]) {
                        $sub->add($related);
                        $coll->remove($k);
                    }
                }

                $this->data[$key]->setRelated($name, $sub);
            }
        } elseif ($rel instanceof Doctrine_Relation_Association) {
            $identifier = $this->_table->getIdentifier();
            $asf        = $rel->getAssociationFactory();
            $name       = $table->getComponentName();

            foreach ($this->data as $key => $record) {
                if ( ! $record->exists()) {
                    continue;
                }
                $sub = Doctrine_Collection::create($table);
                foreach ($coll as $k => $related) {
                    if ($related->get($local) == $record[$identifier]) {
                        $sub->add($related->get($name));
                    }
                }
                $this->data[$key]->setRelated($name, $sub);

            }
        }
    }
开发者ID:nationalfield,项目名称:symfony,代码行数:58,代码来源:Collection.php


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