I am working on a basic blog application with Codeigniter 3.1.8 and Bootstrap 4.
I use migration files (001_create_authors.php
up to 005_create_comments.php
) to automatically create the necessary database tables.
The controller running the migrations is at
application/controllers/Migrate.php
It has the flowing code:
class Migrate extends CI_Controller
{
public function __construct()
{
parent::__construct();
}
public function index()
{
$this->load->library('migration');
if($this->migration->current() === FALSE)
{
show_error($this->migration->error_string());
}
else {
echo 'Migration executed';
}
}
}
The default controller is the Posts
controller, as the routes.php
file shows: $route['default_controller'] = 'posts';
I would like the Posts
controller to redirect to the Migrate
one, if there are no tables in the database. Does Codeigniter have a method to determine if there are no tables? How shall I use it?