Skip to content

Commit bfb6d17

Browse files
committed
Releasing 1.0.1
2 parents 7955477 + 4b5428a commit bfb6d17

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/TgDatabase/Database.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@ protected function connect(\TgUtils\Auth\CredentialsProvider $provider = NULL) {
4848
);
4949
if ($this->con->connect_errno) {
5050
error_log('Failed to connect to MySQL: '.$this->con->connect_errno);
51+
} else {
52+
$this->configureConnection();
5153
}
52-
$this->configureConnection();
5354
}
5455
}
5556

@@ -170,9 +171,20 @@ public function insert_id() {
170171
* @return string error text
171172
*/
172173
public function error() {
174+
if ($this->con->connect_error) {
175+
return $this->con->connect_error;
176+
}
173177
return $this->con->error;
174178
}
175179

180+
/**
181+
* Return TRUE when the database had a problem with the last task.
182+
* @return boolean - TRUE when connection failed or last SQL command failed.
183+
*/
184+
public function hasError() {
185+
return $this->con->connect_errno || $this->con->errno;
186+
}
187+
176188
/**
177189
* Inserts a new row into a table.
178190
* <p>All fields (for objects) or keys (for arrays) are used as column names.</p>

0 commit comments

Comments
 (0)