|
1 | 1 | <?php |
2 | 2 | /** |
3 | | - * Version for PHP 5.4 and later versions. |
| 3 | + * Version for PHP 5.4 and later versions. |
4 | 4 | **/ |
5 | 5 | class SmysqlException extends Exception {}; |
6 | 6 | set_exception_handler(function($e) { |
@@ -80,11 +80,11 @@ public function query($query, $fnc = "Query") { |
80 | 80 | return $this->result; |
81 | 81 | } |
82 | 82 |
|
83 | | - public function queryf($q, $a) { |
| 83 | + public function queryf($q, $a, $fnc = "Queryf") { |
84 | 84 | foreach($a as $k => $v) { |
85 | 85 | $q = str_replace("%" . $k, $this->escape($v), $q); |
86 | 86 | }; |
87 | | - return $this->query($q, "Queryf"); |
| 87 | + return $this->query($q, $fnc); |
88 | 88 | } |
89 | 89 |
|
90 | 90 | public function __set($name, $query) { |
@@ -118,9 +118,9 @@ public function setFnc($name, $query) { |
118 | 118 |
|
119 | 119 | public function execFnc($name, $params = []) { |
120 | 120 | if(isset($this->fncs[$name])) |
121 | | - $this->queryf($this->fncs[$name], $params); |
| 121 | + $this->queryf($this->fncs[$name], $params, $name); |
122 | 122 | else |
123 | | - throw new SmysqlException("(fnc_" . $name . "): This function isn't defined"); |
| 123 | + throw new SmysqlException("(" . $name . "): This function isn't defined"); |
124 | 124 | } |
125 | 125 |
|
126 | 126 | public function dbList() { |
@@ -464,6 +464,12 @@ private function getBool($a, $and, $join = false) { |
464 | 464 | }; |
465 | 465 | return rtrim($r, $and ? " AND " : " OR "); |
466 | 466 | } |
| 467 | + |
| 468 | + public function __sleep() { |
| 469 | + if($this->result instanceof mysqli_result) |
| 470 | + $this->result->free(); |
| 471 | + $this->connect->close(); |
| 472 | + } |
467 | 473 |
|
468 | 474 | public function __wakeup() { |
469 | 475 | $this->__construct($this->host, $this->user, $this->password, $this->db); |
|
0 commit comments