function lmb_tests_setup_db($prefix) { $type = lmbToolkit::instance()->getDefaultDbConnection()->getType(); if (!file_exists($prefix . $type)) { return; } $file = realpath($prefix . $type); lmb_require('limb/dbal/src/lmbDbDump.class.php'); $dump = new lmbDbDump($file); $dump->load(); echo "INFO: Dump is loaded from file '{$file}'\n"; }
/** * @desc Init db * @deps project_db_create * @example project.php init_db -D DSN=mysqli://root:test@localhost/limb_app?charset=utf8 */ function task_project_db_load($argv) { require_once 'limb/dbal/src/lmbDbDump.class.php'; $code = <<<EOD \$toolkit = lmbToolkit :: instance(); echo \$toolkit->getDefaultDbDSN()->toString(); EOD; $output = lmb_cli_run_code_in_project_env($code); $dsn = new lmbDbDSN($output); $conn = lmbToolkit::instance()->createDbConnection($dsn); $dump_file = taskman_prop('PROJECT_DIR') . '/lib/limb/' . taskman_propor('INIT_PACKAGE', 'cms') . '/init/db.' . $conn->getType(); $dump = new lmbDbDump($dump_file, $conn); $dump->load(); taskman_msg("Dump ({$dump_file}) loaded...\n"); }