@@ -21,6 +21,9 @@ class db
21
21
/** This array stores all $connections added so far on execution */
22
22
protected static $ connections = array ();
23
23
24
+ /** This string stores current open connection */
25
+ private static $ connection = "" ;
26
+
24
27
/** This will receive the last inserted row $id */
25
28
protected static $ id = null ;
26
29
@@ -82,11 +85,15 @@ private static function getInstance($key = false)
82
85
self ::useConnection ($ connectionName );
83
86
}
84
87
try {
88
+ if (self ::$ connection !== "" ) {
89
+ return self ::$ connection ;
90
+ }
85
91
$ 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 ' ]);
86
92
if ($ instance ) {
87
93
$ instance ->setAttribute (PDO ::ATTR_EMULATE_PREPARES , false );
88
94
$ instance ->setAttribute (PDO ::ATTR_ERRMODE , PDO ::ERRMODE_EXCEPTION );
89
95
self ::updateTotalRequests ();
96
+ self ::$ connection = $ instance ;
90
97
return $ instance ;
91
98
} else {
92
99
exit ("There's been an error within the database " );
@@ -189,6 +196,7 @@ private static function encapsulate($mixed, $simple = false)
189
196
unset(self ::$ object [$ key ]);
190
197
return false ;
191
198
}
199
+ //print_r(self::$object[$key]);
192
200
return self ::$ object [$ key ];
193
201
}
194
202
if ($ mixed instanceof dbObject) {
@@ -244,7 +252,7 @@ public static function fetchAll($mixed)
244
252
*/
245
253
public static function unsetObject ($ object )
246
254
{
247
- self ::$ object [$ object ->extra ['key ' ]] = "unsetted " ;
255
+ // self::$object[$object->extra['key']] = "unsetted";
248
256
unset(self ::$ object [$ object ->extra ['key ' ]]);
249
257
}
250
258
0 commit comments