protected function _parseYml($folder, $server_name)
 {
     Logger::getInstance('DAO')->addNotice("parseYml() called in Schema for {$server_name}");
     $d = dir($folder);
     $this->_schemas[$server_name] = array();
     while (false !== ($entry = $d->read())) {
         if ($entry == '.' || $entry == '..') {
             continue;
         }
         if (is_dir($folder . DIRECTORY_SEPARATOR . $entry)) {
             continue;
         }
         //check extension
         list($table_name, $extension) = explode('.', $entry);
         if ($extension == 'yml') {
             $filename = $folder . $entry;
             $schema = Yaml::parse($filename);
             if ($schema['name'] != $table_name) {
                 throw new \ORC\Exception\SystemException("Schema file {$entry} doesn't match the table name!");
             }
             $extra_filename = $folder . DIRECTORY_SEPARATOR . 'extra' . DIRECTORY_SEPARATOR . $table_name . '.yml';
             if (file_exists($extra_filename)) {
                 $extra = Yaml::parse($extra_filename);
                 if (!empty($extra)) {
                     $schema['extra info'] = $extra;
                     //use a value can not be used as field name
                     //pre($extra);
                 }
             }
             $this->_schemas[$server_name][$table_name] = new Table\Schema($schema);
         }
     }
     $d->close();
 }
 protected function buildStatement()
 {
     $where = $this->buildWhere();
     if ($where == '') {
         Logger::getInstance('DBAL')->addWarning('delete from ' . $this->_table->getTableName() . ' without WHERE statement!');
     }
     $sql = 'DELETE FROM ' . $this->_table->getTableName() . $where;
     return $sql;
 }
 protected function __construct()
 {
     $base_path = $this->getBasePath();
     if (strpos($_SERVER['REQUEST_URI'], $base_path) === 0) {
         $uri = '/' . substr($_SERVER['REQUEST_URI'], strlen($base_path));
     } else {
         Logger::getInstance('system')->addError(json_encode($_SERVER) . ':' . $base_path);
         throw new \ORC\Exception\SystemException('URL Parse Error');
     }
     $this->_uri = $uri;
     if (substr(strtolower($_SERVER['SERVER_PROTOCOL']), 0, 5) == 'https') {
         $protocol = 'https';
     } else {
         $protocol = 'http';
     }
     //set main server
     $main_server = $protocol . '://' . $_SERVER['HTTP_HOST'] . $base_path;
     \ORC\Core\Config::getInstance()->set('main_server', $main_server);
     //var_dump($this->getBaseURL(), $this->getBasePath());
 }
 public function headersSent()
 {
     $result = headers_sent($filename, $line);
     if ($result) {
         //log the filename and line
         $logger = Logger::getInstance('header');
         $logger->addNotice(sprintf('Headers already sent in %s on line %d', $filename, $line));
     }
     return $result;
 }
 protected function prepare(Dao $dao)
 {
     $sql = $this->buildStatement();
     Logger::getInstance('DBAL')->addInfo("prepared sql:{$sql}");
     return $dao->prepare($sql);
 }
 private function loadConfig($config_name)
 {
     if (in_array($config_name, $this->_config_loaded)) {
         return;
     }
     $this->_config_loaded[] = $config_name;
     if ($config_name == 'cache') {
         //cache config will always read from yml file
         $data = false;
     } else {
         $cacher = CacheFactory::get('config_cache', 'file_config');
         $data = $cacher->getDelay($config_name);
         //$cacher = CacheFactory::get('config_cache', 'config');
         if ($data !== false && $data != ICacher::EMPTY_VALUE) {
             $this->_container->set($config_name, $data);
         }
     }
     if ($data === false) {
         //get from yml file
         $config_file = $this->getConfigFolder() . $config_name . '.yml';
         if (file_exists($config_file)) {
             $data = Yaml::parse($config_file);
             $this->_container->set($config_name, $data);
         }
         //write to cache
         if ($config_name != 'cache') {
             Logger::getInstance('config')->addNotice(sprintf('parse %s file', $config_file));
             if (empty($data)) {
                 $data = ICacher::EMPTY_VALUE;
             }
             $cacher->set($config_name, $data);
         }
     }
 }