Commit 117dd97a authored by Alex Ne's avatar Alex Ne

+ удалялка. и свое исключение на ошибку запросов

parent a63cf7f8
<?php <?php
class XDatabaseParamError extends \X\ETrace\System {} class XDatabaseParamError extends \X\ETrace\System {}
class XDatabaseQueryError extends \X\ETrace\System {}
class X_DB_MySQLi { class X_DB_MySQLi {
/** /**
...@@ -267,7 +268,7 @@ class X_DB_MySQLi { ...@@ -267,7 +268,7 @@ class X_DB_MySQLi {
if (self::$LINK[$this->Connect()->DBLN]->real_query($SQL)) { if (self::$LINK[$this->Connect()->DBLN]->real_query($SQL)) {
return true; return true;
} else { } else {
throw new Exception(self::$LINK[$this->DBLN]->error, self::$LINK[$this->DBLN]->errno); throw new XDatabaseQueryError(self::$LINK[$this->DBLN]->error, self::$LINK[$this->DBLN]->errno, ["SQL" => $SQL, "CLASS" => $this]);
} }
} }
......
...@@ -104,6 +104,12 @@ class TableItem { ...@@ -104,6 +104,12 @@ class TableItem {
return $this; return $this;
} }
public function delete() {
$this->sql_type = "delete";
$this->sql = "DELETE FROM `{$this->table_name}`";
return $this;
}
/** /**
* @param $data * @param $data
* @return mixed * @return mixed
...@@ -326,9 +332,12 @@ class TableItem { ...@@ -326,9 +332,12 @@ class TableItem {
if ($this->sql_type == "select" && $this->driver instanceof \X_DB_MySQLi) { if ($this->sql_type == "select" && $this->driver instanceof \X_DB_MySQLi) {
return $this->driver->get($this->sql . $this->sql_where . $this->sql_order . $this->sql_limit, $op1, $op2, $op3); return $this->driver->get($this->sql . $this->sql_where . $this->sql_order . $this->sql_limit, $op1, $op2, $op3);
} else {
throw new \Exception("Internal error", 0);
} }
if ($this->sql_type == "delete" && $this->driver instanceof \X_DB_MySQLi) {
return $this->driver->rq($this->sql . $this->sql_where);
}
throw new \Exception("Internal error", 0);
} }
} }
?> ?>
\ No newline at end of file
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