Skip to content

Instantly share code, notes, and snippets.

@yuchan
Last active February 23, 2016 14:02
Show Gist options
  • Save yuchan/eb92c76db0de6cf15ff2 to your computer and use it in GitHub Desktop.
Save yuchan/eb92c76db0de6cf15ff2 to your computer and use it in GitHub Desktop.
CodeIgniter Template
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<?php
if (!defined('BASEPATH'))
exit("No direct script access allowed");
class Migrate extends CI_Controller {
public function __construct() {
parent::__construct();
$this->input->is_cli_request()
or exit("Execute via command line: php index.php migrate");
$this->load->library('migration');
}
public function index() {
if (!$this->migration->latest()) {
show_error($this->migration->error_string());
} else {
show_error('You don\'t have permission for this action');
;
}
}
public function version($version) {
if ($this->input->is_cli_request()) {
$migration = $this->migration->version($version);
if (!$migration) {
echo $this->migration->error_string();
} else {
echo 'Migration(s) done' . PHP_EOL;
}
} else {
show_error('You don\'t have permission for this action');
;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment