예제 #1
0
파일: Adapter.php 프로젝트: azema/phigrate
 /**
  * _getIndexName
  *
  * @param string       $tableName  The table name
  * @param string|array $columnName The column name(s)
  * @param array        $options    The options definition of the index
  *
  * @return string
  */
 private function _getIndexName($tableName, $columnName, $options = array())
 {
     //did the user specify an index name?
     if (is_array($options) && array_key_exists('name', $options)) {
         $indexName = $options['name'];
     } else {
         $indexName = Phigrate_Util_Naming::indexName($tableName, $columnName);
     }
     return $indexName;
 }
예제 #2
0
 /**
  */
 public function testIndexName()
 {
     $column = 'first_name';
     $this->assertEquals('idx_users_first_name', Phigrate_Util_Naming::indexName('users', $column));
     $column = 'age';
     $this->assertEquals('idx_users_age', Phigrate_Util_Naming::indexName('users', $column));
     $column = array('listing_id', 'review_id');
     $this->assertEquals('idx_users_listing_id_and_review_id', Phigrate_Util_Naming::indexName('users', $column));
     $column = array('listing_id', 'review_id');
     $this->assertEquals('idx_users_addresses_listing_id_and_review_id', Phigrate_Util_Naming::indexName('users__addresses', $column));
     $column = 'listing__id';
     $this->assertEquals('idx_users_addresses_listing_id', Phigrate_Util_Naming::indexName('users__addresses', $column));
 }