site initialized; basic catalog lists videos
[living-lab-site.git] / application / libraries / Singleton_db.php
1 <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); 
2
3 /**
4  * Library Singleton_db implements a factory that retrieves a single instance
5  * of a Database object for the whole CodeIgniter application.
6  * 
7  * This avoids opening multiple connections to the same database and ensures
8  * that you obtain a Database object only when you need it.
9  *
10  * @category    Controller
11  * @author              Călin-Andrei Burloiu
12  */
13 class Singleton_db {
14         
15         private static $db;
16         
17         function __construct()
18         {
19         }
20         
21         public static function connect()
22         {
23                 if(!isset(self::$db))
24                 {
25                         $CI = & get_instance();
26                         
27                         self::$db = $CI->load->database('default', TRUE);
28                 }
29                 
30                 return self::$db;
31         }
32 }
33
34 /* End of file Singleton_db.php */
35 /* Location: ./application/libraries/Singleton_db.php */