File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff 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>
You can’t perform that action at this time.
0 commit comments