@@ -73,13 +73,14 @@ private static function getInstance()
73
73
self ::useConnection ($ connectionName );
74
74
}
75
75
try {
76
- $ instance = new PDO ('mysql:host= ' . self ::$ connections [self ::$ connectionName ]['HOST ' ] . ";dbname= " . self ::$ connections [self ::$ connectionName ]['NAME ' ] . ";charset=utf8; " , self ::$ connections [self ::$ connectionName ]['USER ' ], self ::$ connections [self ::$ connectionName ]['PASSWORD ' ]);
76
+ $ instance = new PDO ('mysql:host= ' . self ::$ connections [self ::$ connectionName ]['HOST ' ] . ";dbname= " . self ::$ connections [self ::$ connectionName ]['NAME ' ] . "; " , self ::$ connections [self ::$ connectionName ]['USER ' ], self ::$ connections [self ::$ connectionName ]['PASSWORD ' ]);
77
77
if ($ instance ) {
78
78
$ instance ->setAttribute (PDO ::ATTR_EMULATE_PREPARES , false );
79
79
//$connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
80
80
self ::updateTotalRequests ();
81
81
return $ instance ;
82
82
} else {
83
+ exit ("There's been an error within the database " );
83
84
return false ;
84
85
}
85
86
} catch (Exception $ exception ) {
@@ -186,7 +187,15 @@ public static function fetchAll($mixed)
186
187
/** It counts the total rows that $mixed have */
187
188
public static function count ($ mixed )
188
189
{
189
- return self ::encapsulate ($ mixed )->extra ['totalEntries ' ];
190
+ if ($ mixed == null ) {
191
+ return 0 ;
192
+ } else {
193
+ if (is_array ($ mixed )) {
194
+ return 1 ;
195
+ } else {
196
+ return self ::encapsulate ($ mixed )->extra ['totalEntries ' ];
197
+ }
198
+ }
190
199
}
191
200
192
201
/** Checks if the given $query returns null. If it returns null or 0, the function return true (is empty) */
@@ -198,7 +207,7 @@ public static function empty($query)
198
207
if ($ query instanceof dbObject) {
199
208
return ($ query ->getInstance ()->rowCount () == 1 );
200
209
}
201
- if (is_bool ($ query )){
210
+ if (is_bool ($ query )) {
202
211
return !$ query ;
203
212
}
204
213
}
0 commit comments