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


PHP Index::resetColumnsSize方法代码示例

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


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

示例1: testResetColumnsSize

 public function testResetColumnsSize()
 {
     $columns[] = $this->getColumnMock('foo', array('size' => 100));
     $columns[] = $this->getColumnMock('bar', array('size' => 5));
     $index = new Index();
     $index->setColumns($columns);
     $this->assertTrue($index->hasColumnSize('foo'));
     $this->assertTrue($index->hasColumnSize('bar'));
     $index->resetColumnsSize();
     $this->assertFalse($index->hasColumnSize('foo'));
     $this->assertFalse($index->hasColumnSize('bar'));
 }
开发者ID:robin850,项目名称:Propel2,代码行数:12,代码来源:IndexTest.php

示例2: createIndex

 /**
  * Creates a new index.
  *
  * @param  string $name    The index name
  * @param  array  $columns The list of columns to index
  * @return Index  $index   The created index
  */
 protected function createIndex($name, array $columns)
 {
     $index = new Index($name);
     $index->setColumns($columns);
     $index->resetColumnsSize();
     $this->addIndex($index);
     return $index;
 }
开发者ID:disider,项目名称:Propel2,代码行数:15,代码来源:Table.php

示例3: addExtraIndices

 /**
  * Adds extra indices for reverse foreign keys
  * This is required for MySQL databases,
  * and is called from Database::doFinalInitialization()
  */
 public function addExtraIndices()
 {
     /**
      * A collection of indexed columns. The keys is the column name
      * (concatenated with a comma in the case of multi-col index), the value is
      * an array with the names of the indexes that index these columns. We use
      * it to determine which additional indexes must be created for foreign
      * keys. It could also be used to detect duplicate indexes, but this is not
      * implemented yet.
      * @var array
      */
     $_indices = array();
     $this->collectIndexedColumns('PRIMARY', $this->getPrimaryKey(), $_indices);
     $_tableIndices = array_merge($this->getIndices(), $this->getUnices());
     foreach ($_tableIndices as $_index) {
         $this->collectIndexedColumns($_index->getName(), $_index->getColumns(), $_indices);
     }
     // we're determining which tables have foreign keys that point to this table,
     // since MySQL needs an index on any column that is referenced by another table
     // (yep, MySQL _is_ a PITA)
     $counter = 0;
     foreach ($this->referrers as $foreignKey) {
         $referencedColumns = $foreignKey->getForeignColumnObjects();
         $referencedColumnsHash = $this->getColumnList($referencedColumns);
         if (!empty($referencedColumns) && !isset($_indices[$referencedColumnsHash])) {
             // no matching index defined in the schema, so we have to create one
             $name = sprintf('I_referenced_%s_%s', $foreignKey->getName(), ++$counter);
             if ($this->hasIndex($name)) {
                 //if we have already a index with this name, then it looks like the columns of this index have just
                 //been changed, so remove it and inject it again. This is the case if a referenced table is handled
                 //later than the referencing table.
                 $this->removeIndex($name);
             }
             $index = new Index();
             $index->setName($name);
             $index->setColumns($referencedColumns);
             $index->resetColumnsSize();
             $this->addIndex($index);
             // Add this new index to our collection, otherwise we might add it again (bug #725)
             $this->collectIndexedColumns($index->getName(), $referencedColumns, $_indices);
         }
     }
     // we're adding indices for this table foreign keys
     foreach ($this->foreignKeys as $foreignKey) {
         $localColumns = $foreignKey->getLocalColumnObjects();
         $localColumnsHash = $this->getColumnList($localColumns);
         if (!empty($localColumns) && !isset($_indices[$localColumnsHash])) {
             // no matching index defined in the schema, so we have to create one.
             // MySQL needs indices on any columns that serve as foreign keys. these are not auto-created prior to
             // 4.1.2
             $name = substr_replace($foreignKey->getName(), 'FI_', strrpos($foreignKey->getName(), 'FK_'), 3);
             if ($this->hasIndex($name)) {
                 //if we have already a index with this name, then it looks like the columns of this index have just
                 //been changed, so remove it and inject it again. This is the case if a referenced table is handled
                 //later than the referencing table.
                 $this->removeIndex($name);
             }
             $index = new Index();
             $index->setName($name);
             $index->setColumns($localColumns);
             $index->resetColumnsSize();
             $this->addIndex($index);
             $this->collectIndexedColumns($index->getName(), $localColumns, $_indices);
         }
     }
 }
开发者ID:robin850,项目名称:Propel2,代码行数:71,代码来源:Table.php


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