public static function test_field_types_can_be_stored() { $field_types = self::get_field_types(); $specified_table = new Database_SpecifiedTable('ps_foo_bar'); foreach (array_keys($field_types) as $key) { $specified_table->add_field_type($key, $field_types[$key]); } /* * Test that they went in. */ foreach (array_keys($field_types) as $key) { if ($specified_table->get_field_type($key) != $field_types[$key]) { return FALSE; } } return TRUE; }
public static function get_table($table_name) { if (self::table_exists($table_name)) { $table_specification_directory_name = self::get_table_specification_directory_name($table_name); $table = new Database_SpecifiedTable($table_name); foreach (glob($table_specification_directory_name . DIRECTORY_SEPARATOR . '*.type') as $field_file_name) { $field_name = basename($field_file_name); $field_name = preg_replace('/\\.type$/', '', $field_name); $table->add_field_type($field_name, trim(file_get_contents($field_file_name))); } return $table; } else { throw new ErrorHandling_SprintfException('No table specification for \'%s\'!', array($table_name)); } }