3 +-------------------------------------------------------------------------+
4 | Copyright 2010-2011, Davide Franco |
6 | This program is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU General Public License |
8 | as published by the Free Software Foundation; either version 2 |
9 | of the License, or (at your option) any later version. |
11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. |
15 +-------------------------------------------------------------------------+
19 private $config_params;
21 private $catalogs = array();
23 function __construct()
26 $this->config = $config;
29 public function Check_Config_file()
31 // Check if config file exist and is readable
32 return is_readable( CONFIG_FILE );
35 public function Load_Config()
39 if( $this->Check_Config_file() )
40 include_once( CONFIG_FILE );
42 die( "Configuration file not found" );
44 if( is_array($config) && !empty($config) ) {
45 // Loading database connection information
46 foreach( $config as $parameter => $value )
48 if( is_array($value) ) // Parsing database section
49 array_push( $this->catalogs, $value );
57 public function Get_Config_Param( $param )
59 if( isset( $config[$param] ) )
60 return $config[$param];
63 public function Get_Catalogs()
66 foreach( $this->catalogs as $db )
67 array_push( $result, $db['label']);
72 public function Count_Catalogs()
74 return count( $this->catalogs );
77 public function Get_Dsn( $catalog_id )
79 // Construct a valid dsn
81 $dsn['hostspec'] = $this->catalogs[$catalog_id]["host"];
82 $dsn['username'] = $this->catalogs[$catalog_id]["login"];
83 $dsn['password'] = $this->catalogs[$catalog_id]["password"];
84 $dsn['database'] = $this->catalogs[$catalog_id]["db_name"];
85 $dsn['phptype'] = $this->catalogs[$catalog_id]["db_type"];
94 } // end classe BW_Config