@@ -21,6 +21,9 @@ class db
2121 /** This array stores all $connections added so far on execution */
2222 protected static $ connections = array ();
2323
24+ /** This string stores current open connection */
25+ private static $ connection = "" ;
26+ 2427 /** This will receive the last inserted row $id */
2528 protected static $ id = null ;
2629
@@ -82,11 +85,15 @@ private static function getInstance($key = false)
8285 self ::useConnection ($ connectionName );
8386 }
8487 try {
88+ if (self ::$ connection !== "" ) {
89+ return self ::$ connection ;
90+ }
8591 $ 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 ' ]);
8692 if ($ instance ) {
8793 $ instance ->setAttribute (PDO ::ATTR_EMULATE_PREPARES , false );
8894 $ instance ->setAttribute (PDO ::ATTR_ERRMODE , PDO ::ERRMODE_EXCEPTION );
8995 self ::updateTotalRequests ();
96+ self ::$ connection = $ instance ;
9097 return $ instance ;
9198 } else {
9299 exit ("There's been an error within the database " );
@@ -189,6 +196,7 @@ private static function encapsulate($mixed, $simple = false)
189196 unset(self ::$ object [$ key ]);
190197 return false ;
191198 }
199+ //print_r(self::$object[$key]);
192200 return self ::$ object [$ key ];
193201 }
194202 if ($ mixed instanceof dbObject) {
@@ -244,7 +252,7 @@ public static function fetchAll($mixed)
244252 */
245253 public static function unsetObject ($ object )
246254 {
247- self ::$ object [$ object ->extra ['key ' ]] = "unsetted " ;
255+ // self::$object[$object->extra['key']] = "unsetted";
248256 unset(self ::$ object [$ object ->extra ['key ' ]]);
249257 }
250258
0 commit comments