Skip to content
This repository was archived by the owner on May 5, 2020. It is now read-only.

Commit aa8e605

Browse files
authored
Update smysql.php
1 parent 12293dc commit aa8e605

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

smysql.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Version for PHP 5.4 and later versions.
3+
* Version for PHP 5.4 and later versions.
44
**/
55
class SmysqlException extends Exception {};
66
set_exception_handler(function($e) {
@@ -80,11 +80,11 @@ public function query($query, $fnc = "Query") {
8080
return $this->result;
8181
}
8282

83-
public function queryf($q, $a) {
83+
public function queryf($q, $a, $fnc = "Queryf") {
8484
foreach($a as $k => $v) {
8585
$q = str_replace("%" . $k, $this->escape($v), $q);
8686
};
87-
return $this->query($q, "Queryf");
87+
return $this->query($q, $fnc);
8888
}
8989

9090
public function __set($name, $query) {
@@ -118,9 +118,9 @@ public function setFnc($name, $query) {
118118

119119
public function execFnc($name, $params = []) {
120120
if(isset($this->fncs[$name]))
121-
$this->queryf($this->fncs[$name], $params);
121+
$this->queryf($this->fncs[$name], $params, $name);
122122
else
123-
throw new SmysqlException("(fnc_" . $name . "): This function isn't defined");
123+
throw new SmysqlException("(" . $name . "): This function isn't defined");
124124
}
125125

126126
public function dbList() {
@@ -464,6 +464,12 @@ private function getBool($a, $and, $join = false) {
464464
};
465465
return rtrim($r, $and ? " AND " : " OR ");
466466
}
467+
468+
public function __sleep() {
469+
if($this->result instanceof mysqli_result)
470+
$this->result->free();
471+
$this->connect->close();
472+
}
467473

468474
public function __wakeup() {
469475
$this->__construct($this->host, $this->user, $this->password, $this->db);

0 commit comments

Comments
 (0)