コード例 #1
0
ファイル: model_core.php プロジェクト: phpcanvas/phpcanvas
 /**
  * Initializes the cache object.
  * @final
  * @return object
  */
 public function startCache()
 {
     $key = $this->conf;
     if (!is_array($key)) {
         $key = array($key);
     }
     if (empty($key)) {
         App::kill('Cannot start caching without a database configuration.');
     }
     $confs = App::conf('database');
     $keyStr = array();
     foreach ($key as $v) {
         if (!empty($v) && isset($confs[$v])) {
             $keyStr[] = $confs[$v]['username'] . '@' . $confs[$v]['db'];
         }
     }
     if (empty($keyStr)) {
         App::kill('Configuration key cannot be found in database.ini.');
     }
     $key = $this->type . ':' . implode('-', $keyStr);
     $conf = App::conf('file.cache') . '/_modelcache';
     return new FileCache($conf, $key, $this->expiresCache);
 }
コード例 #2
0
ファイル: app.php プロジェクト: phpcanvas/phpcanvas
 /**
  * Loads the required filename of a class.
  * @param string $className the class name to be loaded.
  */
 public static function load($className)
 {
     self::$classes[] = $className;
     $fileName = App::toFileName($className);
     $file = App::file($fileName, substr($fileName, strrpos($fileName, '_') + 1), true);
     if ($file) {
         include $file;
     } else {
         $util = App::file($fileName, 'utility', true);
         if ($util) {
             include $util;
         } else {
             App::kill('Class \'' . $className . '\' cannot be loaded. File not found.');
         }
     }
 }