src/bbn/db.php
public function error($e): void
  {
    $this->has_error = true;
    self::has_error();
    $msg = [
      self::$line,
      self::get_log_line('ERROR DB!'),
      self::$line
    ];
    if ( \is_string($e) ){
      $msg[] = self::get_log_line('USER MESSAGE');
      $msg[] = $e;
    }
    else if ( method_exists($e, 'getMessage') ){
      $msg[] = self::get_log_line('DB MESSAGE');
      $msg[] = $e->getMessage();
    }
    $this->last_error = end($msg);
    $msg[] = self::get_log_line('QUERY');
    $msg[] = $this->last();
    if ( $this->last_params['values'] ){
      $msg[] =  self::get_log_line('VALUES');
      foreach ( $this->last_params['values'] as $v ){
        if ( $v === null ){
          $msg[] = 'NULL';
        }
        else if ( \is_bool($v) ){
          $msg[] = $v ? 'TRUE' : 'FALSE';
        }
        else if ( \is_string($v) ){
          $msg[] = str::is_buid($v) ? bin2hex($v) : str::cut($v, 30);
        }
        else{
          $msg[] = $v;
        }
      }
    }
    $msg[] =  self::get_log_line('BACKTRACE');
    $dbt = array_reverse(debug_backtrace());
    array_walk($dbt, function($a, $i) use(&$msg){
      $msg[] = str_repeat(' ', $i).($i ? '->' : '')."{$a['function']}  (".basename(dirname($a['file'])).'/'.basename($a['file']).":{$a['line']})";
    });
    $this->log(implode(PHP_EOL, $msg));
    if ( $this->on_error === self::E_DIE ){
      die(\defined('BBN_IS_DEV') && BBN_IS_DEV ? '<pre>'.PHP_EOL.implode(PHP_EOL, $msg).PHP_EOL.'</pre>' : 'Database error');
    }
  }
public function error($e): void
  {
    $this->has_error = true;
    self::has_error();
    $msg = [
      self::$line,
      self::get_log_line('ERROR DB!'),
      self::$line
    ];
    if ( \is_string($e) ){
      $msg[] = self::get_log_line('USER MESSAGE');
      $msg[] = $e;
    }
    else if ( method_exists($e, 'getMessage') ){
      $msg[] = self::get_log_line('DB MESSAGE');
      $msg[] = $e->getMessage();
    }
    $this->last_error = end($msg);
    $msg[] = self::get_log_line('QUERY');
    $msg[] = $this->last();
    if ( $this->last_params['values'] ){
      $msg[] =  self::get_log_line('VALUES');
      foreach ( $this->last_params['values'] as $v ){
        if ( $v === null ){
          $msg[] = 'NULL';
        }
        else if ( \is_bool($v) ){
          $msg[] = $v ? 'TRUE' : 'FALSE';
        }
        else if ( \is_string($v) ){
          $msg[] = str::is_buid($v) ? bin2hex($v) : str::cut($v, 30);
        }
        else{
          $msg[] = $v;
        }
      }
    }
    $msg[] =  self::get_log_line('BACKTRACE');
    $dbt = array_reverse(debug_backtrace());
    array_walk($dbt, function($a, $i) use(&$msg){
      $msg[] = str_repeat(' ', $i).($i ? '->' : '')."{$a['function']}  (".basename(dirname($a['file'])).'/'.basename($a['file']).":{$a['line']})";
    });
    $this->log(implode(PHP_EOL, $msg));
    if ( $this->on_error === self::E_DIE ){
      die(\defined('BBN_IS_DEV') && BBN_IS_DEV ? '<pre>'.PHP_EOL.implode(PHP_EOL, $msg).PHP_EOL.'</pre>' : 'Database error');
    }
  }
public function error ( $ e ) : void { $ this -> has_error = true ; self :: has_error ( ) ; $ msg = [ self :: $ line , self :: get_log_line ( 'ERROR DB!' ) , self :: $ line ] ; if ( \ is_string ( $ e ) ) { $ msg [ ] = self :: get_log_line ( 'USER MESSAGE' ) ; $ msg [ ] = $ e ; } else if ( method_exists ( $ e , 'getMessage' ) ) { $ msg [ ] = self :: get_log_line ( 'DB MESSAGE' ) ; $ msg [ ] = $ e -> getMessage ( ) ; } $ this -> last_error = end ( $ msg ) ; $ msg [ ] = self :: get_log_line ( 'QUERY' ) ; $ msg [ ] = $ this -> last ( ) ; if ( $ this -> last_params [ 'values' ] ) { $ msg [ ] = self :: get_log_line ( 'VALUES' ) ; foreach ( $ this -> last_params [ 'values' ] as $ v ) { if ( $ v === null ) { $ msg [ ] = 'NULL' ; } else if ( \ is_bool ( $ v ) ) { $ msg [ ] = $ v ? 'TRUE' : 'FALSE' ; } else if ( \ is_string ( $ v ) ) { $ msg [ ] = str :: is_buid ( $ v ) ? bin2hex ( $ v ) : str :: cut ( $ v , 30 ) ; } else { $ msg [ ] = $ v ; } } } $ msg [ ] = self :: get_log_line ( 'BACKTRACE' ) ; $ dbt = array_reverse ( debug_backtrace ( ) ) ; array_walk ( $ dbt , function ( $ a , $ i ) use ( & $ msg ) { $ msg [ ] = str_repeat ( ' ' , $ i ) . ( $ i ? '->' : '' ) . "{$a['function']}  (" . basename ( dirname ( $ a [ 'file' ] ) ) . '/' . basename ( $ a [ 'file' ] ) . ":{$a['line']})" ; } ) ; $ this -> log ( implode ( PHP_EOL , $ msg ) ) ; if ( $ this -> on_error === self :: E_DIE ) { die ( \ defined ( 'BBN_IS_DEV' ) && BBN_IS_DEV ? '<pre>' . PHP_EOL . implode ( PHP_EOL , $ msg ) . PHP_EOL . '</pre>' : 'Database error' ) ; } }
Set an error and acts appropriately based oon the error mode

@param $e
@return void
Set an error and acts appropriately based oon the error mode