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


PHP Doctrine_Table::getComponentName方法代码示例

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


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

示例1: loadRelated

 /**
  * Load all relationships or the named relationship passed
  *
  * @param mixed $name
  * @return boolean
  */
 public function loadRelated($name = null)
 {
     $list = array();
     $query = new Doctrine_Query($this->_table->getConnection());
     if (!isset($name)) {
         foreach ($this->data as $record) {
             $value = $record->getIncremented();
             if ($value !== null) {
                 $list[] = $value;
             }
         }
         $query->from($this->_table->getComponentName());
         $query->where($this->_table->getComponentName() . '.id IN (' . substr(str_repeat("?, ", count($list)), 0, -2) . ')');
         return $query;
     }
     $rel = $this->_table->getRelation($name);
     if ($rel instanceof Doctrine_Relation_LocalKey || $rel instanceof Doctrine_Relation_ForeignKey) {
         foreach ($this->data as $record) {
             $list[] = $record[$rel->getLocal()];
         }
     } else {
         foreach ($this->data as $record) {
             $value = $record->getIncremented();
             if ($value !== null) {
                 $list[] = $value;
             }
         }
     }
     $dql = $rel->getRelationDql(count($list), 'collection');
     $coll = $query->query($dql, $list);
     $this->populateRelated($name, $coll);
 }
开发者ID:stelaireri,项目名称:Hive,代码行数:38,代码来源:Collection.php

示例2: __construct

 /**
  * constructor, creates tree with reference to table and any options
  *
  * @param object $table                     instance of Doctrine_Table
  * @param array $options                    options
  */
 public function __construct(Doctrine_Table $table, $options)
 {
     $this->table = $table;
     $this->options = $options;
     $this->_baseComponent = $table->getComponentName();
     $class = $this->_baseComponent;
     if ($table->getOption('inheritanceMap')) {
         $subclasses = $table->getOption('subclasses');
         while (in_array($class, $subclasses)) {
             $class = get_parent_class($class);
         }
         $this->_baseComponent = $class;
     }
     //echo $this->_baseComponent;
 }
开发者ID:densem-2013,项目名称:exikom,代码行数:21,代码来源:Tree.php

示例3: addTable

 /**
  * addTable
  * adds a Doctrine_Table object into connection registry
  *
  * @param $table                a Doctrine_Table object to be added into registry
  * @return boolean
  */
 public function addTable(Doctrine_Table $table)
 {
     $name = $table->getComponentName();
     if (isset($this->tables[$name])) {
         return false;
     }
     $this->tables[$name] = $table;
     return true;
 }
开发者ID:seven07ve,项目名称:vendorepuestos,代码行数:16,代码来源:Connection.php

示例4: getTableAsString

 /**
  * Generates a string representation of a table.
  *
  * This method returns an html dump of a table, containing component name
  * and table physical name.
  * @param Doctrine_Table $table
  * @return string
  */
 public static function getTableAsString(Doctrine_Table $table)
 {
     $r[] = "<pre>";
     $r[] = "Component   : " . $table->getComponentName();
     $r[] = "Table       : " . $table->getTableName();
     $r[] = "</pre>";
     return implode("\n", $r) . "<br>";
 }
开发者ID:stelaireri,项目名称:Hive,代码行数:16,代码来源:Lib.php

示例5: completeDefinition

 /**
  * Completes the given definition
  *
  * @param array $def    definition array to be completed
  * @return array        completed definition array
  * @todo Description: What does it mean to complete a definition? What is done (not how)?
  *       Refactor (too long & nesting level)
  */
 public function completeDefinition($def)
 {
     $conn = $this->_table->getConnection();
     $def['table'] = $this->getImpl($def['class']);
     $def['localTable'] = $this->_table;
     $def['class'] = $def['table']->getComponentName();
     $foreignClasses = array_merge($def['table']->getOption('parents'), array($def['class']));
     $localClasses = array_merge($this->_table->getOption('parents'), array($this->_table->getComponentName()));
     $localIdentifierColumnNames = $this->_table->getIdentifierColumnNames();
     $localIdentifierCount = count($localIdentifierColumnNames);
     $localIdColumnName = array_pop($localIdentifierColumnNames);
     $foreignIdentifierColumnNames = $def['table']->getIdentifierColumnNames();
     $foreignIdColumnName = array_pop($foreignIdentifierColumnNames);
     if (isset($def['local'])) {
         $def['local'] = $def['localTable']->getColumnName($def['local']);
         if (!isset($def['foreign'])) {
             // local key is set, but foreign key is not
             // try to guess the foreign key
             if ($def['local'] === $localIdColumnName) {
                 $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;
                     }
                 }
//.........这里部分代码省略.........
开发者ID:densem-2013,项目名称:exikom,代码行数:101,代码来源:Parser.php

示例6: _updateCTIRecord

 /**
  * Class Table Inheritance code.
  * Support dropped for 0.10/1.0.
  */
 private function _updateCTIRecord(Doctrine_Table $table, Doctrine_Record $record)
 {
     $identifier = $record->identifier();
     $dataSet = $this->_formatDataSet($record);
     $component = $table->getComponentName();
     $classes = $table->getOption('joinedParents');
     $classes[] = $component;
     foreach ($record as $field => $value) {
         if ($value instanceof Doctrine_Record) {
             if (!$value->exists()) {
                 $value->save();
             }
             $record->set($field, $value->getIncremented());
         }
     }
     foreach ($classes as $class) {
         $parentTable = $this->conn->getTable($class);
         if (!array_key_exists($class, $dataSet)) {
             continue;
         }
         $this->conn->update($this->conn->getTable($class), $dataSet[$class], $identifier);
     }
 }
开发者ID:sensorsix,项目名称:app,代码行数:27,代码来源:UnitOfWork.php

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

示例8: testInitializingNewTableWorksWithoutConnection

 public function testInitializingNewTableWorksWithoutConnection()
 {
     $table = new Doctrine_Table('Test', $this->conn);
     $this->assertEqual($table->getComponentName(), 'Test');
 }
开发者ID:marekk,项目名称:doctrine1,代码行数:5,代码来源:TableTestCase.php

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