Example #1
0
 public function load($view)
 {
     $file = Registry::getInstance()->app_root . '/View/' . $this->template . '/' . $view . '.php';
     if (file_exists($file)) {
         extract($this->vars, EXTR_REFS);
         include $file;
     } else {
         throw new InvalidViewException('View not found: ' . $view);
     }
 }
Example #2
0
 private static function generateBaseUri()
 {
     $config = Registry::getInstance()->config['uri'];
     $base = $config['scheme'] != null ? $config['scheme'] : 'http';
     $base .= '://';
     $base .= $config['host'] != null ? $config['host'] : $_SERVER['HTTP_HOST'];
     if ($config['port'] != null) {
         $base .= ':' . $config['port'];
     }
     $base .= rtrim('/' . ltrim($config['path'], '/'), '/') . '/';
     static::$base = $base;
 }
Example #3
0
 public function insert(array $contentValues)
 {
     $columns = array_keys($contentValues);
     $sth = $this->generateInsert($columns);
     $this->bindValues($sth, $contentValues);
     $transaction = false;
     if (!Registry::getInstance()->db->inTransaction()) {
         Registry::getInstance()->db->beginTransaction();
         $transaction = true;
     }
     try {
         if ($sth->execute()) {
             $result = Registry::getInstance()->db->lastInsertId();
             if ($transaction) {
                 Registry::getInstance()->db->commit();
             }
             return $result;
         } else {
             if ($transaction) {
                 Registry::getInstance()->db->rollBack();
             }
             return false;
         }
     } catch (\PDOException $e) {
         if ($transaction) {
             Registry::getInstance()->db->rollBack();
         }
         throw $e;
     }
 }