示例#1
0
		'class' => 'PostgreSQLDatabase',
		'title' => 'PostgreSQL 8.3+',
		'helperPath' => 'postgresql/code/PostgreSQLDatabaseConfigurationHelper.php',
		'supported' => function_exists('pg_query'),
		'missingExtensionText' => 'The <a href="http://php.net/pgsql">pgsql</a> PHP extension is not available. Please install or enable it and refresh this page.'
	)
);

DatabaseAdapterRegistry::register(
	array(
		'class' => 'SQLiteDatabase',
		'title' => 'SQLite 3.3+',
		'helperPath' => 'sqlite3/code/SQLiteDatabaseConfigurationHelper.php',
		'supported' => (class_exists('SQLite3') || class_exists('PDO')),
		'missingExtensionText' => 'The <a href="http://php.net/manual/en/book.sqlite3.php">SQLite3</a> and <a href="http://php.net/manual/en/book.pdo.php">PDO</a> classes are not available. Please install or enable one of them and refresh this page.',
		'fields' => array(
			'path' => array(
				'title' => 'Database path<br /><small>Absolute path, writeable by the webserver user.<br />Recommended to be outside of your webroot</small>',
				'default' => realpath(dirname($_SERVER['SCRIPT_FILENAME'])) . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . '.db'
			),
			'database' => array(
				'title' => 'Database name', 
				'default' => 'SS_mysite',
				'attributes' => array(
					"onchange" => "this.value = this.value.replace(/[\/\\:*?&quot;<>|. \t]+/g,'');"
				)
			)
		)
	)
);
<?php

// Register the SilverStripe provided databases
$frameworkPath = defined('FRAMEWORK_PATH') ? FRAMEWORK_PATH : FRAMEWORK_NAME;
// Use MySQLi as default
DatabaseAdapterRegistry::register(array('class' => 'MySQLDatabase', 'title' => 'MySQL 5.0+ (using MySQLi)', 'helperPath' => $frameworkPath . '/dev/install/MySQLDatabaseConfigurationHelper.php', 'supported' => class_exists('MySQLi'), 'missingExtensionText' => 'The <a href="http://www.php.net/manual/en/book.mysqli.php">MySQLi</a>
			PHP extension is not available. Please install or enable it and refresh this page.'));
// Setup MySQL PDO as alternate option
DatabaseAdapterRegistry::register(array('class' => 'MySQLPDODatabase', 'title' => 'MySQL 5.0+ (using PDO)', 'helperPath' => $frameworkPath . '/dev/install/MySQLDatabaseConfigurationHelper.php', 'supported' => class_exists('PDO') && in_array('mysql', PDO::getAvailableDrivers()), 'missingExtensionText' => 'Either the <a href="http://www.php.net/manual/en/book.pdo.php">PDO Extension</a> or
			the <a href="http://www.php.net/manual/en/ref.pdo-mysql.php">MySQL PDO Driver</a>
			are unavailable. Please install or enable these and refresh this page.'));
<?php

$sqliteDatabaseAdapterRegistryFields = array('path' => array('title' => 'Directory path<br /><small>Absolute path to directory, writeable by the webserver user.<br />' . 'Recommended to be outside of your webroot</small>', 'default' => dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . '.sqlitedb'), 'database' => array('title' => 'Database filename (extension .sqlite)', 'default' => 'database.sqlite'));
// Basic SQLLite3 Database
DatabaseAdapterRegistry::register(array('class' => 'SQLite3Database', 'title' => 'SQLite 3.3+ (using SQLite3)', 'helperPath' => dirname(__FILE__) . '/code/SQLiteDatabaseConfigurationHelper.php', 'supported' => class_exists('SQLite3'), 'missingExtensionText' => 'The <a href="http://php.net/manual/en/book.sqlite3.php">SQLite3</a> 
			PHP Extension is not available. Please install or enable it of them and refresh this page.', 'fields' => array_merge($sqliteDatabaseAdapterRegistryFields, array('key' => array('title' => 'Encryption key<br><small>This function is experimental and requires configuration of an ' . 'encryption module</small>', 'default' => '')))));
// PDO database
DatabaseAdapterRegistry::register(array('class' => 'SQLite3PDODatabase', 'title' => 'SQLite 3.3+ (using PDO)', 'helperPath' => dirname(__FILE__) . '/code/SQLiteDatabaseConfigurationHelper.php', 'supported' => class_exists('PDO') && in_array('sqlite', PDO::getAvailableDrivers()), 'missingExtensionText' => 'Either the <a href="http://php.net/manual/en/book.pdo.php">PDO Extension</a> or the
			<a href="http://php.net/manual/en/book.sqlite3.php">SQLite3 PDO Driver</a>
			are unavailable. Please install or enable these and refresh this page.', 'fields' => $sqliteDatabaseAdapterRegistryFields));
<?php

// PDO connector for MS SQL Server
DatabaseAdapterRegistry::register(array('class' => 'MSSQLPDODatabase', 'title' => 'SQL Server 2008 (using PDO)', 'helperPath' => dirname(__FILE__) . '/code/MSSQLDatabaseConfigurationHelper.php', 'supported' => class_exists('PDO') && in_array('sqlsrv', PDO::getAvailableDrivers()), 'missingExtensionText' => 'Either the <a href="http://www.php.net/manual/en/book.pdo.php">PDO Extension</a> or 
		the <a href="http://www.php.net/manual/en/ref.pdo-sqlsrv.php">SQL Server PDO Driver</a> 
		are unavailable. Please install or enable these and refresh this page.'));
// Basic driver using sqlsrv connector
DatabaseAdapterRegistry::register(array('class' => 'MSSQLDatabase', 'title' => 'SQL Server 2008 (using sqlsrv)', 'helperPath' => dirname(__FILE__) . '/code/MSSQLDatabaseConfigurationHelper.php', 'supported' => function_exists('sqlsrv_connect'), 'missingExtensionText' => 'The <a href="http://www.microsoft.com/sqlserver/2005/en/us/PHP-Driver.aspx">sqlsrv</a>
		PHP extensions is not available. Please install or enable it and refresh this page.', 'fields' => array_merge(DatabaseAdapterRegistry::get_default_fields(), array('windowsauthentication' => array('title' => 'Use Windows authentication? (leave blank for false)', 'default' => '')))));
// MS Azure uses an online database
DatabaseAdapterRegistry::register(array('class' => 'MSSQLAzureDatabase', 'title' => 'MS Azure Database (using sqlsrv)', 'helperPath' => dirname(__FILE__) . '/code/MSSQLDatabaseConfigurationHelper.php', 'supported' => function_exists('sqlsrv_connect'), 'missingExtensionText' => 'The <a href="http://www.microsoft.com/sqlserver/2005/en/us/PHP-Driver.aspx">sqlsrv</a>
		PHP extension is not available. Please install or enable it and refresh this page.'));
<?php

// PDO Postgre database
DatabaseAdapterRegistry::register(array('class' => 'PostgrePDODatabase', 'title' => 'PostgreSQL 8.3+ (using PDO)', 'helperPath' => dirname(__FILE__) . '/code/PostgreSQLDatabaseConfigurationHelper.php', 'supported' => class_exists('PDO') && in_array('postgresql', PDO::getAvailableDrivers()), 'missingExtensionText' => 'Either the <a href="http://www.php.net/manual/en/book.pdo.php">PDO Extension</a> or 
		the <a href="http://www.php.net/manual/en/ref.pdo-sqlsrv.php">SQL Server PDO Driver</a> 
		are unavailable. Please install or enable these and refresh this page.'));
// PDO Postgre database
DatabaseAdapterRegistry::register(array('class' => 'PostgreSQLDatabase', 'title' => 'PostgreSQL 8.3+ (using pg_connect)', 'helperPath' => dirname(__FILE__) . '/code/PostgreSQLDatabaseConfigurationHelper.php', 'supported' => function_exists('pg_connect'), 'missingExtensionText' => 'The <a href="http://php.net/pgsql">pgsql</a> PHP extension is not
		available. Please install or enable it and refresh this page.'));