Esempio n. 1
0
 /**
  * Tests getting all indices from a table.
  *
  * @depends testCreateTable
  * @covers empire\framework\db\DB::getIndices
  *
  * @param DB[] $dbs the database objects to work on
  */
 public function testGetIndices($dbs)
 {
     foreach ($dbs as $db) {
         /* @var $db DB */
         $this->assertEquals(array(self::$index->getName() => self::$index), $db->getIndices('test'));
     }
 }
Esempio n. 2
0
 /**
  * Builds a [UNIQUE] INDEX (field1, field2, .
  *
  *
  *
  *
  *
  *
  * ..) definition that can be used in CREATE or ALTER statements.
  *
  * @param Index $index the index
  * @return string the definition statement
  */
 private function buildIndexDefinition(Index $index)
 {
     $res = '';
     if ($index->getUnique()) {
         $res .= 'UNIQUE ';
     }
     $res .= 'INDEX ';
     $res .= $index->getName();
     $res .= ' (';
     $res .= '`' . implode('`,`', $index->getFields()) . '`';
     $res .= ')';
     return $res;
 }
Esempio n. 3
0
 /**
  * Adds an index to this table.
  *
  * @param Index $index the index to add
  */
 public final function addIndex(Index $index)
 {
     $this->indices[$index->getName()] = $index;
 }