Exemple #1
0
 public function testRenameTable()
 {
     $cfg = Db_Object_Config::getInstance('Page', true);
     $uniqName = uniqid();
     $o = new Db_Object_Builder('Page', false);
     $renamed = $o->renameTable($uniqName);
     if (!$renamed) {
         echo implode("\n", $o->getErrors());
     }
     $this->assertTrue($renamed);
     $cfg->getConfig()->set('table', $uniqName);
     Model::removeInstance('Page');
     $o = new Db_Object_Builder('Page', false);
     $renamed = $o->renameTable('content');
     if (!$renamed) {
         echo implode("\n", $o->getErrors());
     }
     $this->assertTrue($renamed);
     $cfg->getConfig()->set('table', 'content');
 }
Exemple #2
0
 /**
  * Build object action
  */
 public function buildAction()
 {
     $this->_checkCanEdit();
     $name = Request::post('name', 'string', false);
     if (!$name) {
         Response::jsonError($this->_lang->WRONG_REQUEST);
     }
     if (!Db_Object_Config::configExists($name)) {
         Response::jsonError($this->_lang->WRONG_REQUEST);
     }
     $builder = new Db_Object_Builder($name);
     if (!$builder->build() || !$builder->buildForeignKeys()) {
         Response::jsonError($this->_lang->CANT_EXEC . ' ' . implode(',', $builder->getErrors()));
     }
     Response::jsonSuccess();
 }
Exemple #3
0
 * and save a reference for it (for convenience)
 * @var Config_Simple $appConfig
 */
$appConfig = Config::factory(Config::Simple, 'main');
$appConfig->setData($config);
Registry::set('main', $appConfig, 'config');
/**
 * Convert the data of main_config file
 * in to the general form of configuration
 * and save a reference for it (for convenience)
 * @var Config_Simple $appConfig
 */
/*
 * Starting the application
 */
$app = new Application($appConfig);
$app->setAutoloader($autoloader);
$app->init();
//  build objects
$objectFiles = File::scanFiles($config['object_configs'], array('.php'), false, File::Files_Only);
foreach ($objectFiles as $file) {
    $object = substr(basename($file), 0, -4);
    echo 'build ' . $object . ' : ';
    $builder = new Db_Object_Builder($object);
    if ($builder->build()) {
        echo 'OK';
    } else {
        echo 'Error! ' . strip_tags(implode(', ', $builder->getErrors()));
    }
    echo "\n";
}