Commit 4fb87a3e authored by Alex Ne's avatar Alex Ne

Багфикс

parent d531f032
......@@ -128,7 +128,7 @@ class TableItem {
$this->sql_type = "first";
$columns = func_get_args();
if ($this->driver instanceof \X\Database\Driver\PDO) {
$this->data_columns = $columns;
$this->data_columns = (isset($columns[0])) ? $columns[0] : "*";
return $this;
}
......@@ -152,7 +152,7 @@ class TableItem {
$columns = func_get_args();
if ($this->driver instanceof \X\Database\Driver\PDO) {
$this->data_columns = $columns;
$this->data_columns = (isset($columns[0])) ? $columns[0] : "*";
return $this;
}
......
......@@ -293,9 +293,7 @@ class PDO {
* @param $columns
*/
private function build_columns(&$columns) {
if (count($columns) == 1 && is_array($columns[0])) {
$columns = "`" . implode("`,`", $columns[0]) . "`";
} else if (count($columns) > 1) {
if (is_array($columns) && count($columns) > 0) {
$columns = "`" . implode("`,`", $columns) . "`";
} else {
$columns = "*";
......
......@@ -124,9 +124,11 @@ class ECollection implements \IteratorAggregate, \ArrayAccess, \Countable {
*/
public function offsetSet($offset, $object) {
$this->__check_type($object);
$offset = $object->getHash();
$this->context_collection[$offset][] = $object->getContext();
$object->clean_context();
$offset = $object->getHash();
if (count($object->getContext()) > 0) {
$this->context_collection[$offset][] = $object->getContext();
$object->clean_context();
}
if (isset($this->__collection[$offset])) {
$this->__collection[$offset]->increment();
} else {
......
......@@ -9,7 +9,7 @@ class EItem extends \Exception {
/**
* @var mixed
*/
protected $run_context;
protected $context;
/**
* @var int
*/
......@@ -47,7 +47,7 @@ class EItem extends \Exception {
* @return mixed
*/
public function __construct($type, $message, $code = 0, $file = false, $line = false, $context = []) {
parent::__construct($message, $code);
parent::__construct($message, intval($code));
if ( ! ($file === false)) {
$this->file = $file;
}
......@@ -55,8 +55,9 @@ class EItem extends \Exception {
if ( ! ($line === false)) {
$this->line = $line;
}
$this->type = $type;
$this->run_context = $context;
$this->context = $context;
$this->hash = $this->calcHash();
$this->host = isset($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : "no.host";
$this->session_id = md5(microtime());
......@@ -81,7 +82,14 @@ class EItem extends \Exception {
* @return mixed
*/
public function getContext() {
return $this->run_context;
return $this->context;
}
/**
* @param $context
*/
public function setContext($context) {
$this->context = $context;
}
/**
......@@ -103,8 +111,8 @@ class EItem extends \Exception {
"count" => $this->count,
"trace" => $this->Trace(),
"message" => $this->message,
"context" => $this->context,
"object_name" => $this->object_name,
"context" => $this->run_context,
];
}
......@@ -120,7 +128,7 @@ class EItem extends \Exception {
}
public function clean_context() {
$this->run_context = [];
$this->context = [];
}
/**
......
......@@ -26,7 +26,7 @@ class Import extends EItem {
}
/**
* @return array
* @return mixed
*/
public function Trace() {
return $this->trace;
......
<?php
namespace X\ETrace;
class Trace extends EItem
{
class Trace extends EItem {
/**
* Упрощенный интерфейс для отладки кода, проверки стека и переменных окружения.
*
* @param $message
* @param array $context
*/
public function __construct($message, $context = [])
{
parent::__construct("trace", $message, 0, false, false, $context);
public function __construct($context = []) {
parent::__construct("trace", "System Trace", 0, false, false, $context);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment