static function init() { $dbs = \Hiano\App\App::getConfig()->get('hitar:database'); $first = NULL; foreach ($dbs as $dk => $dv) { if ($first === NULL) { $first = $dk; } \Hitar\DatabaseManager::addDatabase($dk, $dv); } if ($first) { \Hitar\DatabaseManager::selectDatabase($first); } }
* @primary * @generator guid */ public $id; /** * * @field string(length:100) */ public $name; } $db_path = __DIR__ . '/test.sqlite'; if (file_exists($db_path)) { unlink($db_path); } \Hitar\DatabaseManager::addDatabase('test', ['driver' => 'pdo_sqlite', 'user' => '', 'password' => '', 'path' => $db_path]); \Hitar\DatabaseManager::selectDatabase('test'); function init() { $tb = Test::table(); $sm = $tb->getConnection()->getSchemaManager(); $schema = $sm->createSchema(); $new_tb = $schema->createTable('test'); $new_tb->addColumn('nickname', 'string', ['length' => 100]); $new_tb2 = $schema->createTable('tableexample'); $new_tb2->addColumn('id', 'string', ['length' => 100]); $new_tb2->addColumn('name', 'string', ['length' => 100]); $sqls = $schema->toSql($tb->getConnection()->getDatabasePlatform()); foreach ($sqls as $q) { $tb->getConnection()->exec($q); } }