Esempio n. 1
0
 /**
  * Database constructor
  *
  * @param mixed $mConfig 	- config array or name of config
  * @return void
  */
 private function __construct($mConfig)
 {
     // get Lithium instance
     if (!$this->oLithium instanceof Lithium) {
         $this->oLithium = Lithium::getInstance();
     }
     if (empty($mConfig)) {
         // load default db config
         $this->loadConfig($this->oLithium->getConfig('database'), 'default');
     } elseif (is_array($mConfig)) {
         $this->loadConfig($mConfig, 'default');
     } elseif (is_string($mConfig)) {
         // load specified db config
         $this->loadConfig($this->oLithium->getConfig('database'), $mConfig);
     }
     if (empty($this->aConfig)) {
         throw new Lithium_Exception_Database('database.error_config');
     }
     // get driver name
     $sDriver = $this->getDriverName();
     // load driver
     $this->oDriver = new $sDriver($this->aConfig);
     // clean pass field
     $this->aConfig['pass'] = '';
 }
Esempio n. 2
0
File: User.php Progetto: maxwroc/PHP
 public static function tryCreate($sLogin)
 {
     $oLithium = Lithium::getInstance();
     $aUsers = $oLithium->getConfig('users');
     if ($aUsers == null || $aUsers[$sLogin] == null) {
         return null;
     }
     return new Model_User($sLogin, $aUsers[$sLogin]);
 }
Esempio n. 3
0
<?php

defined('SYSPATH') or die('No direct access!');
if (IN_PRODUCTION) {
    error_reporting(E_ALL ^ E_NOTICE);
} else {
    error_reporting(E_ALL);
}
define('EXT', '.php');
define('DOCROOT', realpath(getcwd() . DIRECTORY_SEPARATOR . SYSPATH) . DIRECTORY_SEPARATOR);
include SYSPATH . 'Lithium/Loader' . EXT;
Loader::registerAutoload();
$oLithium = Lithium::getInstance();
$oConfig = new Config($aConfig);
$oLithium->setConfig($oConfig);
$oLithium->setRouter(new Router($oConfig));
// let a magic happen :)
$oLithium->Dispatch();
// display warnings
if (!IN_PRODUCTION && !empty($aLithiumWarnings)) {
    echo implode('<br />', $aLithiumWarnings);
}