本文整理汇总了PHP中OA_DB::setSchema方法的典型用法代码示例。如果您正苦于以下问题:PHP OA_DB::setSchema方法的具体用法?PHP OA_DB::setSchema怎么用?PHP OA_DB::setSchema使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OA_DB
的用法示例。
在下文中一共展示了OA_DB::setSchema方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: singleton
//.........这里部分代码省略.........
}
if (!(count($aConnections) > 0) || !in_array($dsnMd5, $aConnections)) {
// Prepare options for a new database connection
$aOptions = array();
// Sequence column name
$aOptions['seqcol_name'] = 'id';
// Set the index name format
$aOptions['idxname_format'] = '%s';
// Use 4 decimal places in DECIMAL nativetypes
$aOptions['decimal_places'] = 4;
// Set the portability options
$aOptions['portability'] = OA_DB_MDB2_DEFAULT_OPTIONS;
// Set the default table type for MySQL, if appropriate
if (strcasecmp($databaseType, 'mysql') === 0) {
if (!empty($aConf['table']['type'])) {
$aOptions['default_table_type'] = $aConf['table']['type'];
// Enable transaction support when using InnoDB tables
if (strcasecmp($aOptions['default_table_type'], 'innodb') === 0) {
// Enable transaction support
$aOptions['use_transactions'] = true;
}
}
} elseif (strcasecmp($databaseType, 'pgsql') === 0) {
$aOptions['quote_identifier'] = true;
}
// Add default charset - custom OpenX
if (defined('OA_DB_MDB2_DEFAULT_CHARSET')) {
$aOptions['default_charset'] = OA_DB_MDB2_DEFAULT_CHARSET;
} else {
$aOptions['default_charset'] = 'utf8';
}
// this will log select queries to a var/sql.log
// currently used for analysis purposes
if (isset($aConf['debug']['logSQL']) && $aConf['debug']['logSQL']) {
$aOptions['log_statements'] = explode('|', $aConf['debug']['logSQL']);
$aOptions['debug'] = true;
$aOptions['debug_handler'] = 'logSQL';
}
$aOptions += OA_DB::getDatatypeMapOptions();
// Is this a MySQL database connection?
if (strcasecmp($databaseType, 'mysql') === 0) {
// Should this connection happen over SSL?
if (@$aDriverOptions['ssl']) {
$aOptions['ssl'] = true;
}
}
// Create the new database connection
OA::disableErrorHandling();
$oDbh = MDB2::singleton($dsn, $aOptions);
OA::enableErrorHandling();
if (PEAR::isError($oDbh)) {
return $oDbh;
}
// Is this a MySQL database connection?
if (strcasecmp($databaseType, 'mysql') === 0) {
$client_flags = 0;
// Should this connection happen over SSL?
if (@$aDriverOptions['ssl']) {
$client_flags = $client_flags | MYSQL_CLIENT_SSL;
}
// Should this connection use compression?
if (@$aDriverOptions['compress']) {
$client_flags = $client_flags | MYSQL_CLIENT_COMPRESS;
}
// Are there any MySQL connection flags to set?
if ($client_flags != 0) {
$oDbh->dsn['client_flags'] = $client_flags;
}
}
OA::disableErrorHandling();
$success = $oDbh->connect();
OA::enableErrorHandling();
if (PEAR::isError($success)) {
return $success;
}
// Set charset if needed
$success = OA_DB::setCharset($oDbh);
if (PEAR::isError($success)) {
return $success;
}
// Set schema if needed
$success = OA_DB::setSchema($oDbh);
if (PEAR::isError($success)) {
return $success;
}
// Set the fetchmode to be use used
$oDbh->setFetchMode(MDB2_FETCHMODE_ASSOC);
// Load modules that are likely to be needed
$oDbh->loadModule('Extended');
$oDbh->loadModule('Datatype');
$oDbh->loadModule('Manager');
// Store the database connection
$GLOBALS['_OA']['CONNECTIONS'][$dsnMd5] = $oDbh;
// Set MySQL 4 compatibility if needed
if (strcasecmp($databaseType, 'mysql') === 0 && !empty($aConf['database']['mysql4_compatibility'])) {
$oDbh->exec("SET SESSION sql_mode='MYSQL40'");
}
}
return $GLOBALS['_OA']['CONNECTIONS'][$dsnMd5];
}