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]);
} }
} }
......
...@@ -39,7 +39,7 @@ class TableItem { ...@@ -39,7 +39,7 @@ class TableItem {
} }
/** /**
* @param $Data * @param $Data
* @return mixed * @return mixed
*/ */
public function insert($Data) { public function insert($Data) {
...@@ -49,7 +49,7 @@ class TableItem { ...@@ -49,7 +49,7 @@ class TableItem {
} }
/** /**
* @param $Data * @param $Data
* @return mixed * @return mixed
*/ */
public function replace($Data) { public function replace($Data) {
...@@ -104,8 +104,14 @@ class TableItem { ...@@ -104,8 +104,14 @@ 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
*/ */
public function where($data) { public function where($data) {
...@@ -114,9 +120,9 @@ class TableItem { ...@@ -114,9 +120,9 @@ class TableItem {
} }
/** /**
* @param $data * @param $data
* @param $operator * @param $operator
* @param false $gr * @param false $gr
* @return mixed * @return mixed
*/ */
private function where_clause($data, $operator = false, $gr = false) { private function where_clause($data, $operator = false, $gr = false) {
...@@ -293,7 +299,7 @@ class TableItem { ...@@ -293,7 +299,7 @@ class TableItem {
} }
/** /**
* @param $data * @param $data
* @return mixed * @return mixed
*/ */
private function escape($data) { private function escape($data) {
...@@ -310,9 +316,9 @@ class TableItem { ...@@ -310,9 +316,9 @@ class TableItem {
} }
/** /**
* @param $op1 * @param $op1
* @param false $op2 * @param false $op2
* @param false $op3 * @param false $op3
* @return mixed * @return mixed
*/ */
public function exec($op1 = false, $op2 = false, $op3 = false) { public function exec($op1 = false, $op2 = false, $op3 = false) {
...@@ -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