method error documentation in bbn\Db\HasError

Set an error and acts appropriately based oon the error mode

function($e) { $this->_has_error = true; self::_set_has_error_all(); $msg = [ self::$LINE, self::getLogLine('ERROR DB!'), self::$LINE ]; if (\is_string($e)) { $msg[] = self::getLogLine('USER MESSAGE'); $msg[] = $e; } elseif (method_exists($e, 'getMessage')) { $msg[] = self::getLogLine('DB MESSAGE'); $msg[] = $e->getMessage(); } $this->last_error = end($msg); $msg[] = self::getLogLine('QUERY'); $msg[] = $this->last(); if (($last_real_params = $this->getRealLastParams()) && !empty($last_real_params['values'])) { $msg[] = self::getLogLine('VALUES'); foreach ($last_real_params['values'] as $v){ if ($v === null) { $msg[] = 'NULL'; } elseif (\is_bool($v)) { $msg[] = $v ? 'TRUE' : 'FALSE'; } elseif (\is_string($v)) { $msg[] = Str::isBuid($v) ? bin2hex($v) : Str::cut($v, 30); } else{ $msg[] = $v; } } } $msg[] = self::getLogLine('BACKTRACE'); $dbt = array_reverse(debug_backtrace()); array_walk( $dbt, function ($a, $i) use (&$msg) { if (isset($a['file'])) { $msg[] = str_repeat(' ', $i). ($i ? '->' : ''). "{$a['function']} (". X::basename(X::dirname($a['file'])).'/'. X::basename($a['file']).":{$a['line']})"; } } ); $this->log(implode(PHP_EOL, $msg)); if ($this->on_error === Errors::E_EXCEPTION) { throw new \Exception(X::join($msg, PHP_EOL)); } elseif ($this->on_error === Errors::E_DIE) { throw new \Exception(X::join($msg, PHP_EOL)); die(); } }

Set an error and acts appropriately based oon the error mode BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way

This website uses cookies to ensure you get the best experience on our website.