/** * Creates a new Model. * * If 'dbName' is null then it will use the default database (the first one in the config file). * * If 'dbName' is null and there is no default database, then none is picked and the 'db' field * will not be present in this object. */ public function __construct($dbName = null) { parent::__construct(); $flexi = Flexi::getFlexi(); // setup the db if ($dbName == null) { $dbConfig = $flexi->getDefaultDatabase(); } else { $dbConfig = $flexi->getDatabase($dbName); } if ($dbConfig == null) { if ($dbName != null) { throw new Exception('Database configuration not found, database: ' . $dbName); } } else { $this->load->obj('obj/database', 'db', null, $dbConfig); } }
/** * Standard constructor. Creates a new Controller and it builds it's own Loader object. */ public function __construct() { parent::__construct(); $this->flexi = Flexi::getFlexi(); $isInsideView = false; }
/** * Creates a new Loader which is associated to work on the controller given. * This means that any objects it loads (through the obj method) will be * assigned to this given controller. * * @param controller The controller to associate with this loader. */ public function __construct($parentObj) { $this->flexi = Flexi::getFlexi(); $this->parentObj = $parentObj; }
/** * Generates the SQL query from the settings placed onto this database object * and returns it. No query is performed and the database is left unaltered. * * This is mainly for debugging purposes and so you can get copies of the SQL * that your queries will make. * * @return The SQL code to perform the query currently setup on this database object. */ private function generateSQL() { $sql = ''; $ar =& $this->activerecord; $isSelect = false; if (!isset($ar['table'])) { throw new Exception("No table selected in query."); } // INSERT values if (isset($ar['update_on'])) { $sql = $this->generateSQLUpdate(); } else { if (isset($ar['insert'])) { if (count($ar['table']) > 1) { throw new Exception("Multiple tables selected on insert (can only select one)."); } $sql = $this->generateSQLInsert(); } else { if (isset($ar['delete'])) { $sql = $this->generateSQLDelete(); } else { $sql = $this->generateSQLSelect(); $isSelect = true; } } } $debugSaveSQL = Flexi::getFlexi()->get('database_save_sql'); if ($debugSaveSQL) { $file = fopen($debugSaveSQL, 'a'); fwrite($file, $sql . "\n"); fclose($file); } return new DBSQLQuery($sql, $ar['table'], $isSelect); }
<?php if (!defined('ACCESS_OK')) { exit('Can\'t access scripts directly!'); } /** * Config * * Site wide settings are set in this script. It is devided into different sections * for each area. */ $flexi = Flexi::getFlexi(); /* --- --- --- * Environment Settings * --- --- --- */ // Uncomment to have the DB save it's generated SQL in '/sql.txt' // $flexi->set( 'database_save_sql', 'sql.txt' ); // when missing user activation is on by default // $flexi->set( 'disable_user_activation_links', true ); /* --- --- --- * Setup * --- --- --- */ // The default controller and the default method to use when none is selected or found. $flexi->setDefaultController('home', 'index'); // The URI location of the root folder for your site. Only alter this // if it's located within a sub-folder. // In that case it should be '/sub-folder/' $flexi->setRootURI("/"); /* --- --- --- * Paths - to find stuff * --- --- --- */