/**
  * Removes a version
  */
 public static function delete_version($version)
 {
     $table = NimbleRecord::$adapter->quote_table_name(static::migration_table_name());
     $query = new NimbleQuery(NimbleQuery::DELETE);
     $query->from = $table;
     $query->where = NimbleQuery::condition('version', $version);
     $sql = $query->build();
     Migration::execute($sql);
 }
Exemple #2
0
 /**
  * Runs the table migration converting the table object into runable sql
  */
 public function go()
 {
     (string) ($sql = $this->sql);
     $sql .= ' (' . join(", ", $this->columns) . ')';
     $sql .= ' ' . $this->options;
     $out = array(Migration::execute($sql));
     foreach ($this->other as $other) {
         array_push($out, Migration::execute($other));
     }
     return $out;
 }
Exemple #3
0
 /**
  * Executes all the table alters in the order they were added
  */
 public function go($test = false)
 {
     foreach ($this->columns as $sql) {
         if (!$test) {
             Migration::execute($sql . ";");
         }
     }
 }
Exemple #4
0
 public function __construct($controller = null)
 {
     /* Set config */
     $this->config = array();
     $file_loc = SYSDOCS_DIR . '/config/json/_config.json';
     $config_data = is_file($file_loc) ? json_decode(file_get_contents($file_loc), true) : array();
     if (defined('CONFIG_NAME')) {
         $config_names = explode("\t", CONFIG_NAME);
         foreach ($config_names as $config_name) {
             if (!isset($config_data[$config_name])) {
                 continue;
             }
             foreach ($config_data[$config_name] as $key => $value) {
                 defined($key) || !strlen($value) || define($key, $value);
             }
         }
     }
     $file_loc = SYSDOCS_DIR . '/config/json/_notice.json';
     $notice_datas = is_file($file_loc) ? json_decode(file_get_contents($file_loc), true) : array();
     $validate_massages = array();
     foreach ($notice_datas as $notice_data) {
         if ($notice_data['category'] === 'validate') {
             $validate_massages[$notice_data['code']] = $notice_data['message'];
         }
         $this->notice_msgs[$notice_data['category']][$notice_data['code']] = $notice_data['message'];
     }
     count($validate_massages) && define('VALIDATE_MESSAGE', json_encode($validate_massages));
     require_once SYSDOCS_DIR . '/config/common.php';
     file_exists(SYSDOCS_DIR . '/config/local.php') && (require_once SYSDOCS_DIR . '/config/local.php');
     defined('TEMPLATE_CACHE_DIR') || define('TEMPLATE_CACHE_DIR', $this->view()->get_cachedir());
     if (defined('LINEAR_BENCHMARK_FLAG') && LINEAR_BENCHMARK_FLAG) {
         $this->benchmark = new Benchmark(SYSDOCS_DIR . '/log/benchmark_log');
     }
     if (defined('LINEAR_MIGRATION_FLAG') && LINEAR_MIGRATION_FLAG && is_dir(SYSDOCS_DIR . '/config/database')) {
         Migration::execute(SYSDOCS_DIR . '/config/database', $this);
     }
     $this->query = array_merge($_GET, $_POST);
     if (!empty($this->query)) {
         if (function_exists('mb_detect_encoding') && function_exists('mb_convert_encoding')) {
             $this->dec = mb_detect_encoding($this->_implode_query($this->query), 'UTF-8, EUC-JP, Shift_JIS');
         }
         $this->query = $this->_convert_query($this->query);
     }
     defined('ROUTE_CONTROLLER') || define('ROUTE_CONTROLLER', get_class($this));
     $this->session = new Session(ROUTE_CONTROLLER);
     $this->userdata = array();
     $GLOBALS['controller'] = $this;
     spl_autoload_register(function ($class_name) {
         $class_name = strtolower($class_name);
         if (substr($class_name, 0, 13) == 'linear\\model\\') {
             $model_dirs = explode('\\', $class_name);
             array_shift($model_dirs);
             array_shift($model_dirs);
             $model_loc = SYSDOCS_DIR . '/model/' . implode('/', $model_dirs) . '.php';
             if (is_file($model_loc)) {
                 require_once $model_loc;
             }
         }
     });
 }