@@ -67,14 +67,15 @@ public function step2Action()
67
67
}
68
68
$ this ->view ->header = 'Step 2: Database Configuration ' ;
69
69
70
- $ databases = array ('mysql ' , 'pgsql ' );
70
+ $ databases = array ('mysql ' , 'pgsql ' , ' sqlite ' );
71
71
$ this ->view ->databaseType = array ();
72
72
foreach ($ databases as $ database ) {
73
73
if (!extension_loaded ('pdo_ ' .$ database ) || !file_exists (BASE_PATH .'/core/database/ ' .$ database )
74
74
) {
75
75
unset($ database );
76
76
} else {
77
77
$ form = $ this ->Form ->Install ->createDBForm ();
78
+ $ host = $ form ->getElement ('host ' );
78
79
$ port = $ form ->getElement ('port ' );
79
80
$ username = $ form ->getElement ('username ' );
80
81
switch ($ database ) {
@@ -86,6 +87,11 @@ public function step2Action()
86
87
$ port ->setValue ('5432 ' );
87
88
$ username ->setValue ('postgres ' );
88
89
break ;
90
+ case 'sqlite ' :
91
+ $ host ->setValue ('' );
92
+ $ port ->setValue ('' );
93
+ $ username ->setValue ('' );
94
+ break ;
89
95
default :
90
96
break ;
91
97
}
@@ -144,16 +150,18 @@ public function step2Action()
144
150
$ driverOptions = array ();
145
151
$ params = array (
146
152
'dbname ' => $ form ->getValue ('dbname ' ),
147
- 'username ' => $ form ->getValue ('username ' ),
148
- 'password ' => $ form ->getValue ('password ' ),
149
153
'driver_options ' => $ driverOptions ,
150
154
);
151
- $ unixsocket = $ form ->getValue ('unix_socket ' );
152
- if ($ unixsocket ) {
153
- $ params ['unix_socket ' ] = $ unixsocket ;
154
- } else {
155
- $ params ['host ' ] = $ form ->getValue ('host ' );
156
- $ params ['port ' ] = $ form ->getValue ('port ' );
155
+ if ($ dbtype != 'PDO_SQLITE ' ) {
156
+ $ params ['username ' ] = $ form ->getValue ('username ' );
157
+ $ params ['password ' ] = $ form ->getValue ('password ' );
158
+ $ unixsocket = $ form ->getValue ('unix_socket ' );
159
+ if ($ unixsocket ) {
160
+ $ params ['unix_socket ' ] = $ unixsocket ;
161
+ } else {
162
+ $ params ['host ' ] = $ form ->getValue ('host ' );
163
+ $ params ['port ' ] = $ form ->getValue ('port ' );
164
+ }
157
165
}
158
166
159
167
$ db = Zend_Db::factory ($ dbtype , $ params );
@@ -176,9 +184,11 @@ public function step2Action()
176
184
$ configGlobal = new Zend_Config_Ini (LOCAL_CONFIGS_PATH .'/application.local.ini ' , 'global ' );
177
185
Zend_Registry::set ('configGlobal ' , $ configGlobal );
178
186
187
+ $ configDatabase = new Zend_Config_Ini (LOCAL_CONFIGS_PATH .'/database.local.ini ' , $ configGlobal ->environment );
188
+ Zend_Registry::set ('configDatabase ' , $ configDatabase );
189
+
179
190
require_once BASE_PATH .'/core/controllers/components/UpgradeComponent.php ' ;
180
191
$ upgradeComponent = new UpgradeComponent ();
181
- $ db = Zend_Registry::get ('dbAdapter ' );
182
192
183
193
$ upgradeComponent ->initUpgrade ('core ' , $ db , $ dbtype );
184
194
$ upgradeComponent ->upgrade (str_replace ('.sql ' , '' , basename ($ sqlFile )));
@@ -268,31 +278,36 @@ public function testconnectionAction()
268
278
$ this ->requireAjaxRequest ();
269
279
$ this ->_helper ->layout ->disableLayout ();
270
280
$ this ->_helper ->viewRenderer ->setNoRender ();
271
- try {
272
- $ driverOptions = array ();
273
- $ params = array (
274
- 'dbname ' => $ this ->getParam ('dbname ' ),
275
- 'username ' => $ this ->getParam ('username ' ),
276
- 'password ' => $ this ->getParam ('password ' ),
277
- 'driver_options ' => $ driverOptions ,
278
- );
279
- $ unixsocket = $ this ->getParam ('unix_socket ' );
280
- if ($ unixsocket ) {
281
- $ params ['unix_socket ' ] = $ this ->getParam ('unix_socket ' );
282
- } else {
283
- $ params ['host ' ] = $ this ->getParam ('host ' );
284
- $ params ['port ' ] = $ this ->getParam ('port ' );
285
- }
286
- $ db = Zend_Db::factory ('PDO_ ' .strtoupper ($ this ->getParam ('type ' )), $ params );
287
- $ tables = $ db ->listTables ();
288
- if (count ($ tables ) > 0 ) {
289
- $ return = array (false , 'The database is not empty ' );
290
- } else {
291
- $ return = array (true , 'The database is reachable ' );
281
+ $ dbtype = 'PDO_ ' .strtoupper ($ this ->getParam ('type ' ));
282
+ if ($ dbtype === 'PDO_SQLITE ' ) {
283
+ $ return = array (true , 'The database is reachable ' );
284
+ } else {
285
+ try {
286
+ $ driverOptions = array ();
287
+ $ params = array (
288
+ 'dbname ' => $ this ->getParam ('dbname ' ),
289
+ 'username ' => $ this ->getParam ('username ' ),
290
+ 'password ' => $ this ->getParam ('password ' ),
291
+ 'driver_options ' => $ driverOptions ,
292
+ );
293
+ $ unixsocket = $ this ->getParam ('unix_socket ' );
294
+ if ($ unixsocket ) {
295
+ $ params ['unix_socket ' ] = $ this ->getParam ('unix_socket ' );
296
+ } else {
297
+ $ params ['host ' ] = $ this ->getParam ('host ' );
298
+ $ params ['port ' ] = $ this ->getParam ('port ' );
299
+ }
300
+ $ db = Zend_Db::factory ('PDO_ ' .strtoupper ($ this ->getParam ('type ' )), $ params );
301
+ $ tables = $ db ->listTables ();
302
+ if (count ($ tables ) > 0 ) {
303
+ $ return = array (false , 'The database is not empty ' );
304
+ } else {
305
+ $ return = array (true , 'The database is reachable ' );
306
+ }
307
+ $ db ->closeConnection ();
308
+ } catch (Zend_Exception $ exception ) {
309
+ $ return = array (false , 'Could not connect to the database ' );
292
310
}
293
- $ db ->closeConnection ();
294
- } catch (Zend_Exception $ exception ) {
295
- $ return = array (false , 'Could not connect to the database ' );
296
311
}
297
312
echo JsonComponent::encode ($ return );
298
313
}
0 commit comments