/** * Constructor. Children who define a __construct method should call this. * * Connect to db, setup request params, etc. */ public function __construct() { // Let CI init things (e.g. loader, etc.). parent::__construct(); AIR2_DBManager::init(); // load output library ASAP, in case anything goes wrong $this->load->library('AirOutput'); // set the is_production flag based on setting in app/init.php if (AIR2_ENVIRONMENT == 'prod') { $this->is_production = true; } // request data $this->method = $this->router->http_method; $this->view = $this->router->http_view; $this->decode_input($this->method); $this->begin(); }
#!/usr/bin/env php <?php require_once realpath(dirname(__FILE__) . '/../app/init.php'); require_once 'AIR2_DBManager.php'; /** * create-tbl.php * * This utility lets you create single tables from doctrine models. * */ AIR2_DBManager::init(); $conn = AIR2_DBManager::get_master_connection(); echo "Enter the name of the Doctrine model > "; $modelname = trim(fgets(STDIN)); if (strlen($modelname) < 1) { echo "Error! No model specified!\n"; exit(1); } try { $tbl = Doctrine::getTable($modelname); } catch (Exception $e) { echo "Error!\n" . $e->getMessage() . "\n"; exit(1); } try { $conn->execute('describe ' . $tbl->getTableName()); echo "Table already exists in database!\nDrop table and recreate? (y/n) > "; $drop = strtolower(trim(fgets(STDIN))); if ($drop == 'y') { try { $conn->execute('drop table ' . $tbl->getTableName());
/** * Load database connection in constructor */ public function __construct() { parent::__construct(); AIR2_DBManager::init(); }