public function test_index_name() { $column = "first_name"; $this->assertEquals("idx_users_first_name", Ruckusing_NamingUtil::index_name("users", $column)); $column = "age"; $this->assertEquals("idx_users_age", Ruckusing_NamingUtil::index_name("users", $column)); $column = array('listing_id', 'review_id'); $this->assertEquals("idx_users_listing_id_and_review_id", Ruckusing_NamingUtil::index_name("users", $column)); }
public function has_index($table_name, $column_name, $options = array()) { if (empty($table_name)) { throw new Ruckusing_ArgumentException("Missing table name parameter"); } if (empty($column_name)) { throw new Ruckusing_ArgumentException("Missing column name parameter"); } //did the user specify an index name? if (is_array($options) && array_key_exists('name', $options)) { $index_name = $options['name']; } else { $index_name = Ruckusing_NamingUtil::index_name($table_name, $column_name); } $indexes = $this->indexes($table_name); foreach ($indexes as $idx) { if ($idx['name'] == $index_name) { return true; } } return false; }