Thursday, March 10, 2016

export database without phpmyadmin

Hi! sometimes you need to get database, but you haven't phpmyadmin/sqladminer nor or you just want to do it faster.
So you can do it loggining via ssh and use some mysql command or create script with

<?php
exec('mysqldump --user=MYUSERNAME --password=MYPASSWORD --host=localhost MYDATABASENAME > backup.sql');
exit('done');

and run it

Thursday, March 3, 2016

Extending multiple controllers in Code Igniter

Hi! If you are forced to use old framework like codeigniter, and want to have multiple base controllers and then extend them here a trick you can do:

1) check the value of
$config['subclass_prefix'] = 'MY_';
in application\config\config.php
By default it is MY_ ; but nvm check to make sure.
2) create php file called MY_Controller.php (or your %prefix%Controller.php inside application\core folder
3) In this file (MY_Controller.php) you can create any amount of base controllers that extends CI_Controller, and then in simple controllers extend these base controllers
<?phpif (!defined('BASEPATH')) {    exit('No direct script access allowed');}

class Admin_Controller extends CI_Controller{    }
class Public_Controller extends CI_Controller{
}