Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3306433

Browse filesBrowse files
authored
Update ssql.php
Fixed some error throwing
1 parent 8375a9c commit 3306433
Copy full SHA for 3306433

File tree

Expand file treeCollapse file tree

1 file changed

+12
-5
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+12
-5
lines changed
Open diff view settings
Collapse file

‎ssql.php‎

Copy file name to clipboardExpand all lines: ssql.php
+12-5Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ public function __construct($e, $code = 0, Throwable $previous = NULL) {
3232
}
3333
public function __toString() {
3434
ob_start();
35-
trigger_error("<strong>SuperSQL error</strong> " . $this->message . " in <strong>" . $this->file . "</strong> on line <strong>" . $this->line . "</strong>");
35+
trigger_error("<strong>SuperSQL error:</strong> " . $this->message . " in <strong>" . $this->file . "</strong> on line <strong>" . $this->line . "</strong>");
3636
ob_clean();
3737
if(ini_get("display_errors"))
38-
die("<br /><strong>SuperSQL error</strong> " . $this->message . " in <strong>" . $this->file . "</strong> on line <strong>" . $this->line . "</strong>");
38+
die("<br /><strong>SuperSQL error:</strong> " . $this->message . " in <strong>" . $this->file . "</strong> on line <strong>" . $this->line . "</strong>");
3939
else
4040
exit;
4141
return "<strong>SuperSQL error</strong> " . $this->message;
@@ -105,7 +105,7 @@ public function __construct($host = "", $user = "", $password = "", $database =
105105
$this->user = $user;
106106
$this->password = $password;
107107
$this->db = $database;
108-
if(str_replace("create[", "", $database)!=$database && end(str_split($database))=="]") {
108+
if(str_replace("create[", "", $database)!=$database && $split = str_split($database) && end($split)=="]") {
109109
$new = str_replace("]", "", str_replace("create[", "", $database));
110110
$this->connect = @new PDO("mysql:host=" . $host, $user, $password);
111111
if(!$this->query("
@@ -118,7 +118,7 @@ public function __construct($host = "", $user = "", $password = "", $database =
118118
$this->connect = @new PDO("mysql:" . (empty($database) ? "" : "dbname=" . $database . ";") . "host=" . $host . ";charset=utf8", $user, $password);
119119
} catch(PDOException $e) {
120120
throw new SSQLException("(__construct): Cannot connect to MySQL: " . $e->getMessage());
121-
}
121+
};
122122
if($this->connect->errorCode() && $this->connect) {
123123
throw new SSQLException("(__construct): Cannot select MySQL database:" . $this->connect->errorInfo()[2]);
124124
$this->connect->close();
@@ -154,7 +154,14 @@ public function query($query, $flags = 0, $fnc = "Query") {
154154
print "<pre><strong>" . ucwords($fnc) . ":</strong> " . htmlentities($query) . "</pre>";
155155
if(empty($this->db) && !$this->SQLite && !in_array($fnc, ["__construct", "changeDB", "dbList"]))
156156
throw new SSQLException("(" . $fnc . "): No database selected");
157-
$qr = $this->connect->query($query);
157+
try {
158+
$qr = $this->connect->query($query);
159+
} catch(PDOException $e) {
160+
if($flags & self::NO_ERROR)
161+
return false;
162+
else
163+
throw new SSQLException("(" . $fnc . "): Database error: <em>{$e->getMessage()}</em> <strong>SQL query:</strong> <code>" . (empty($query) ? "<em>Missing</em>" : $query) . "</code>");
164+
};
158165
if(!$qr && !($flags & self::NO_ERROR))
159166
throw new SSQLException("(" . $fnc . "): Database error: <em>{$this->connect->errorInfo()[2]}</em> <strong>SQL query:</strong> <code>" . (empty($query) ? "<em>Missing</em>" : $query) . "</code>");
160167
elseif(!$qr)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.