2010-01-14 20:46:47 +00:00
< ? php
2010-03-12 02:37:17 +00:00
$classes = array ( 'SQLiteDatabase' , 'SQLite3Database' , 'SQLitePDODatabase' );
2010-02-08 04:20:09 +00:00
2010-03-12 02:37:17 +00:00
global $databaseConfig ;
if ( defined ( 'SS_DATABASE_CLASS' ) && in_array ( SS_DATABASE_CLASS , $classes )) {
$databaseConfig [ 'type' ] = SS_DATABASE_CLASS ;
}
2010-01-21 11:32:21 +00:00
2010-03-12 02:37:17 +00:00
if ( in_array ( $databaseConfig [ 'type' ], $classes )) {
2010-03-10 23:57:41 +00:00
if ( empty ( $databaseConfig [ 'path' ])) $databaseConfig [ 'path' ] = defined ( 'SS_SQLITE_DATABASE_PATH' ) && SS_SQLITE_DATABASE_PATH ? SS_SQLITE_DATABASE_PATH : ASSETS_PATH . '/.sqlitedb/' ; // where to put the database file
$databaseConfig [ 'database' ] = ( defined ( 'SS_DATABASE_PREFIX' ) ? SS_DATABASE_PREFIX : '' ) . $databaseConfig [ 'database' ] . ( defined ( 'SS_DATABASE_SUFFIX' ) ? SS_DATABASE_SUFFIX : '' );
if ( ! isset ( $databaseConfig [ 'memory' ])) $databaseConfig [ 'memory' ] = true ; // run tests in memory
if ( empty ( $databaseConfig [ 'key' ])) $databaseConfig [ 'key' ] = defined ( 'SS_SQLITE_DATABASE_KEY' ) && SS_SQLITE_DATABASE_KEY ? SS_SQLITE_DATABASE_KEY : 'SQLite3DatabaseKey' ;
2010-01-24 06:57:42 +00:00
/**
* set pragma values on the connection .
* @ see http :// www . sqlite . org / pragma . html
*/
2010-06-13 22:20:21 +00:00
SQLite3Database :: $default_pragma [ 'encoding' ] = '"UTF-8"' ;
SQLite3Database :: $default_pragma [ 'locking_mode' ] = 'NORMAL' ;
2010-01-21 11:32:21 +00:00
// The SQLite3 class is available in PHP 5.3 and newer
2010-04-14 03:07:20 +00:00
if ( class_exists ( 'SQLite3' ) && $databaseConfig [ 'type' ] != 'SQLitePDODatabase' ) {
2010-01-21 11:32:21 +00:00
$databaseConfig [ 'type' ] = 'SQLite3Database' ;
2010-03-12 02:37:17 +00:00
} else {
$databaseConfig [ 'type' ] = 'SQLitePDODatabase' ;
2010-01-21 11:32:21 +00:00
}
2010-03-12 02:37:17 +00:00
}