/** * Load database driver to query for results **/ private function _getDriver() { require_once APPPATH . 'libraries/scaffolder/drivers/driver' . EXT; return Driver::getDriver(); }
/** * Verify if database driver is functional */ public function testDriver() { require BASEPATH . 'codeigniter/Common' . EXT; require BASEPATH . 'codeigniter/Compat' . EXT; require APPPATH . 'config/constants' . EXT; require BASEPATH . 'codeigniter/Base5' . EXT; require_once APPPATH . 'libraries/scaffolder/drivers/driver' . EXT; $test_table = 'cidade'; $num_fields = 4; $pk = "id"; $driver = Driver::getDriver(); $tables = $driver->getTables(); $this->assert(in_array($test_table, $tables), true, "Show test table"); $fields = $driver->getFields($test_table); $this->assert(count($fields), $num_fields, "Display {$num_fields} fields"); $primary_key = $this->getTablePK($fields); $this->assertNotNull($primary_key, "Has primary key"); $this->assert($primary_key->getName(), $pk, "Primary Key equals {$pk}"); }