Rev 66 | Rev 69 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 66 | Rev 68 | ||
---|---|---|---|
Line 150... | Line 150... | ||
150 | * <code>dbname</code>, which allows for aliases, all
|
150 | * <code>dbname</code>, which allows for aliases, all
|
151 | * keys are ignored if the corresponding properties
|
151 | * keys are ignored if the corresponding properties
|
152 | * were set. That is, definitions in the class file
|
152 | * were set. That is, definitions in the class file
|
153 | * override those in the configuration file.
|
153 | * override those in the configuration file.
|
154 | *
|
154 | *
|
155 | * @return boolean|array
|
155 | * @return array|boolean
|
156 | * <code>true</code> if the configuration
|
156 | * The configuration array if the configuration
|
157 | * file could be read, the configuration array otherwise.
|
157 | * file could be read, <code>false</code> otherwise.
|
158 | */
|
158 | */
|
159 | public function readConfig () |
159 | public function readConfig () |
160 | {
|
160 | {
|
161 | $config = parse_ini_file('application/.config', true); |
161 | $config = parse_ini_file('application/.config', true); |
162 | if ($config !== false) |
162 | if ($config !== false) |
163 | {
|
163 | {
|
164 | $section = 'database:' . $this->_dbname; |
164 | $section = 'database:' . $this->_dbname; |
165 | if (isset($config[$section])) |
165 | if (isset($config[$section])) |
166 | {
|
166 | {
|
167 | $dbconfig = $config[$section]; |
167 | $dbconfig = $config[$section]; |
- | 168 | $options = array( |
|
168 | foreach (array('host', 'dbname', 'username', 'password', 'charset') as $key) |
169 | 'host', 'port', 'dbname', 'username', 'password', 'charset' |
- | 170 | ); |
|
- | 171 | ||
- | 172 | foreach ($options as $key) |
|
169 | {
|
173 | {
|
170 | $property = "_$key"; |
174 | $property = "_$key"; |
171 | if (isset($dbconfig[$key]) |
175 | if (isset($dbconfig[$key]) |
172 | && $key == 'dbname' |
176 | && $key == 'dbname' |
173 | || (property_exists($this, $property) |
177 | || (property_exists($this, $property) |
174 | && $this->$property === null)) |
178 | && $this->$property === null)) |
175 | {
|
179 | {
|
176 | $this->$property = $dbconfig[$key]; |
180 | $this->$property = $dbconfig[$key]; |
177 | }
|
181 | }
|
178 | }
|
182 | }
|
- | 183 | ||
- | 184 | return $config[$section]; |
|
179 | }
|
185 | }
|
180 | }
|
186 | }
|
181 | 187 | ||
182 | return $config; |
188 | return $config; |
183 | }
|
189 | }
|