예제 #1
0
function peach_error_handler($errno, $errstr, $errfile, $errline)
{
    $msg = "{$errno} : {$errstr} in {$errline} of {$errfile}";
    Error::log($msg);
    ExceptionHandler::show_error('an error occurred');
    return true;
}
예제 #2
0
 /**
  * @throws \InvalidArgumentException
  */
 private function set_title()
 {
     /**
      * @var $router Router
      */
     $router = Application::get_class(Router::class);
     $pageModel = $router->current_page();
     if ($pageModel) {
         $title = $this->titles[$pageModel->name];
         if (is_array($title)) {
             list($class, $method, $prefix) = array_pad($title, 3, '');
             try {
                 $reflection_method = new \ReflectionMethod($class, $method);
                 $params = $router->get_route_params();
                 $params[] = $prefix;
                 if ($reflection_method->isStatic()) {
                     $this->current = call_user_func_array([$class, $method], $params);
                 } else {
                     $this->current = call_user_func_array([Application::get_class($class), $method], $params);
                 }
             } catch (\Exception $e) {
                 Error::log($e->getMessage());
             }
         } else {
             $this->current = $title;
         }
     }
 }
예제 #3
0
 public function initialize()
 {
     mb_internal_encoding('UTF-8');
     mb_http_output('UTF-8');
     mb_http_input('UTF-8');
     \common\classes\Error::initialize();
     \System\handler\ExceptionHandler::initialize();
     /**
      * @var $session Session
      */
     $session = \common\classes\Application::get_class(Session::class);
     $session->start();
 }
예제 #4
0
 public function execute($sql = null)
 {
     try {
         if ($sql) {
             $this->statement = $this->db->query($sql);
         } else {
             $sth = $this->db->prepare($this->query);
             $i = 1;
             foreach ($this->bind_values as $value) {
                 $sth->bindValue($i++, $value);
             }
             $sth->execute();
             $this->statement = $sth;
             $this->bind_values = [];
         }
     } catch (\PDOException $e) {
         Error::log($e->getMessage());
         Error::log($this->query);
     }
     return $this;
 }
예제 #5
0
 /**
  * @covers common\classes\Error::log
  */
 public function test_log()
 {
     Error::log('log test');
 }