本文整理汇总了PHP中MDB2_Schema::factory方法的典型用法代码示例。如果您正苦于以下问题:PHP MDB2_Schema::factory方法的具体用法?PHP MDB2_Schema::factory怎么用?PHP MDB2_Schema::factory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MDB2_Schema
的用法示例。
在下文中一共展示了MDB2_Schema::factory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* The constructor method.
*/
function __construct()
{
parent::__construct();
$this->oDbh = OA_DB::singleton();
$this->oCache = new OA_DB_XmlCache();
$this->oSchema =& MDB2_Schema::factory($this->oDbh, array('force_defaults' => false));
}
示例2: Test_OA_DB_XmlCache
/**
* The constructor method.
*/
function Test_OA_DB_XmlCache()
{
$this->UnitTestCase();
$this->oDbh = OA_DB::singleton();
$this->oCache = new OA_DB_XmlCache();
$this->oSchema =& MDB2_Schema::factory($this->oDbh, array('force_defaults' => false));
}
示例3: removeDashboardColumns
function removeDashboardColumns()
{
$this->oSchema = MDB2_Schema::factory(OA_DB::singleton(OA_DB::getDsn()));
$prefix = $GLOBALS['_MAX']['CONF']['table']['prefix'];
$table = 'preference';
$aColumns = array('ad_clicks_sum', 'ad_views_sum', 'ad_clicks_per_second', 'ad_views_per_second', 'ad_cs_data_last_sent', 'ad_cs_data_last_sent', 'ad_cs_data_last_received');
OA_DB::setCaseSensitive();
$aDef = $this->oSchema->getDefinitionFromDatabase(array($prefix . $table));
OA_DB::disableCaseSensitive();
if (is_array($aDef) && count($aDef) > 0) {
$aTask['remove'] = array();
if (isset($aDef['tables'][$prefix . $table])) {
foreach ($aColumns as $column) {
if (isset($aDef['tables'][$prefix . $table]['fields'][$column])) {
$aTask['remove'][$column] = array();
$this->oUpgrade->oLogger->logOnly("preference.{$column} found");
}
}
}
if (count($aTask['remove'] > 0)) {
$result = $this->oSchema->db->manager->alterTable($prefix . $table, $aTask, false);
}
}
$this->oUpgrade->oLogger->logOnly('preference table schema upgrade for dashboard unnecessary');
return true;
}
示例4: init
/**
* verify the input file
* instantiate the schema and table objects
*
* @param string $datafile
* @param string $directory
* @return boolean
*/
function init($datafile = 'fjsdj', $directory = '/tests/datasets/mdb2schema/')
{
if (!parent::init()) {
return false;
}
if (!$directory) {
$directory = '/tests/datasets/mdb2schema/';
}
$this->directory = $directory;
if (substr_count($this->directory, MAX_PATH) < 1) {
$this->directory = MAX_PATH . $this->directory;
}
$this->datafile = $datafile;
if (!file_exists($this->directory . $this->datafile)) {
return false;
}
$this->oSchema =& MDB2_Schema::factory($this->oDbh);
if (PEAR::isError($this->oSchema)) {
return false;
}
$this->oTable = new OA_DB_Table();
if (PEAR::isError($this->oTable)) {
return false;
}
return true;
}
示例5: alterDatabaseActionTable
function alterDatabaseActionTable()
{
$this->oSchema = MDB2_Schema::factory(OA_DB::singleton(OA_DB::getDsn()));
$prefix = $GLOBALS['_MAX']['CONF']['table']['prefix'];
OA_DB::setCaseSensitive();
$aPrev = $this->oSchema->getDefinitionFromDatabase(array($prefix . 'database_action'));
OA_DB::disableCaseSensitive();
$aCurr = $this->_getLatestDatabaseActionSchema($prefix);
$aChanges = $this->oSchema->compareDefinitions($aCurr, $aPrev);
if (is_array($aChanges) && count($aChanges) > 0) {
if (isset($aChanges['tables']['change'][$prefix . 'database_action'])) {
if (isset($aChanges['tables']['change'][$prefix . 'database_action']['indexes']['add']['database_action_pkey'])) {
unset($aChanges['tables']['change'][$prefix . 'database_action']['indexes']['add']['database_action_pkey']);
unset($aChanges['tables']['change'][$prefix . 'database_action']['indexes']['change']);
}
if (isset($aChanges['tables']['change'][$prefix . 'database_action']['add']['database_action_id'])) {
$result = $this->oSchema->alterDatabase($aCurr, $aPrev, $aChanges);
if (PEAR::isError($result)) {
$this->oUpgrade->oLogger->logError($result->getUserInfo());
return false;
}
$this->oUpgrade->oLogger->log('database_action table schema successfully upgraded');
return true;
}
}
}
$this->oUpgrade->oLogger->log('database_action table schema upgrade unnecessary');
return true;
}
示例6: setUp
function setUp()
{
PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'catchErrorHandlerPEAR');
$this->dsn = $GLOBALS['dsn'];
$this->options = $GLOBALS['options'];
$this->database = $GLOBALS['database'];
$this->dsn['database'] = $this->database;
$this->schema =& MDB2_Schema::factory($this->dsn, $this->options);
if (PEAR::isError($this->schema)) {
$this->assertTrue(false, 'Could not connect to manager in setUp');
exit;
}
}
示例7: setUpDatabase
function setUpDatabase()
{
// Create a new test table, overwriting old ones.
require_once 'MDB2/Schema.php';
$config = $this->getDriverConfig();
$manager = MDB2_Schema::factory($config['params']);
$defs = $manager->parseDatabaseDefinition(dirname(dirname(__DIR__)) . '/scripts/sql/test.xml', false, array('name' => $config['params']['database']), false);
$result = $manager->createTable('hordetest_turba_objects', $defs['tables']['hordetest_turba_objects'], true);
$this->assertOk($result);
foreach ($this->_fixtures as $fixture) {
$this->assertOk($this->_insert($fixture));
}
}
示例8: setUp
function setUp()
{
PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'catchErrorHandlerPEAR');
$this->dsn = $GLOBALS['dsn'];
$this->options = $GLOBALS['options'];
$this->database = $GLOBALS['database'];
$this->dsn['database'] = $this->database;
$this->schema =& MDB2_Schema::factory($this->dsn, $this->options);
if (PEAR::isError($this->schema)) {
$this->assertTrue(false, 'Could not connect to manager in setUp');
exit;
}
$this->aSchemas = array(1 => SCHEMA_PATH . 'schema_1_original.xml', 2 => SCHEMA_PATH . 'schema_2_newfield.xml', 3 => SCHEMA_PATH . 'schema_3_primarykey.xml', 4 => SCHEMA_PATH . 'schema_4_idxfieldorder.xml', 5 => SCHEMA_PATH . 'schema_5_fieldtype.xml', 6 => SCHEMA_PATH . 'schema_6_removefield.xml', 7 => SCHEMA_PATH . 'schema_7_removeindex.xml', 8 => SCHEMA_PATH . 'schema_8_addtable.xml', 9 => SCHEMA_PATH . 'schema_9_removetable.xml', 10 => SCHEMA_PATH . 'schema_10_keyfield.xml');
}
示例9: setUp
function setUp()
{
$this->dsn = $GLOBALS['dsn'];
$this->options = $GLOBALS['options'];
$this->database = $GLOBALS['database'];
$backup_file = $this->driver_input_file . $this->backup_extension;
if (file_exists($backup_file)) {
unlink($backup_file);
}
$backup_file = $this->lob_input_file . $this->backup_extension;
if (file_exists($backup_file)) {
unlink($backup_file);
}
$this->schema =& MDB2_Schema::factory($this->dsn, $this->options);
if (PEAR::isError($this->schema)) {
$this->assertTrue(false, 'Could not connect to manager in setUp');
exit;
}
}
示例10: generateXmlCache
function generateXmlCache($xmlFiles, $callback = 'parseDatabaseDefinitionFile')
{
global $aSkipFiles, $aOptions, $oDbh, $oCache;
foreach ($xmlFiles as $fileName) {
if (!in_array(baseName($fileName), $aSkipFiles)) {
echo " => " . basename($fileName) . ": ";
flush();
$oSchema =& MDB2_Schema::factory($oDbh, $aOptions);
$result = $oSchema->{$callback}($fileName, true);
if (PEAR::isError($result)) {
clean_up();
die("Failed\n");
} else {
$oCache->save($result, $fileName);
echo "Processed";
eol_flush();
}
unset($result);
}
}
}
示例11: setUp
function setUp()
{
PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'catchErrorHandlerPEAR');
$this->dsn = $GLOBALS['dsn'];
$this->options = $GLOBALS['options'];
$this->database = $GLOBALS['database'];
$this->dsn['database'] = $this->database;
$backup_file = SCHEMA_PATH . $this->driver_input_file . $this->backup_extension;
if (file_exists($backup_file)) {
unlink($backup_file);
}
$backup_file = SCHEMA_PATH . $this->lob_input_file . $this->backup_extension;
if (file_exists($backup_file)) {
unlink($backup_file);
}
$this->schema =& MDB2_Schema::factory($this->dsn, $this->options);
if (PEAR::isError($this->schema)) {
$this->assertTrue(false, 'Could not connect to manager in setUp');
exit;
}
}
示例12: __construct
/**
* php5 class constructor
*
* @param string The XML schema file we are working on
*/
function __construct($file_schema = 'tables_core.xml', $file_changes = '', $path_schema)
{
$this->oLogger = new OA_UpgradeLogger();
$this->oLogger->setLogFile('schema.log');
if (empty($path_schema)) {
$path_schema = '/etc/';
}
if (!empty($path_schema) && substr($path_schema, 0, 1) != '/') {
$path_schema = '/' . $path_schema;
}
if (!empty($path_schema) && substr($path_schema, strlen($path_schema) - 4, 4) != 'etc/') {
$path_schema = $path_schema . 'etc/';
}
$this->path_schema_final = MAX_PATH . $path_schema;
$this->path_schema_trans = MAX_PATH . '/var/';
$this->path_changes_final = MAX_PATH . $path_schema . 'changes/';
$this->path_changes_trans = MAX_PATH . '/var/';
if ($path_schema == '/etc/') {
$this->path_dbo = MAX_PATH . '/lib/max/Dal/DataObjects/';
} else {
$this->path_dbo = $this->path_schema_final . 'DataObjects/';
}
//$this->path_links_final = MAX_PATH.'/lib/max/Dal/DataObjects/';
$this->path_links_final = $this->path_dbo;
$this->path_links_trans = MAX_PATH . '/var/';
$file_changes = $file_changes ? $file_changes : 'changes_' . $file_schema;
$file_links = 'db_schema.links.ini';
$this->schema_final = $this->path_schema_final . $file_schema;
$this->schema_trans = $this->path_schema_trans . $file_schema;
$this->oLogger->log($this->schema_final);
$this->use_links = $file_schema == 'tables_core.xml';
if ($this->use_links) {
$this->links_final = $this->path_links_final . $file_links;
$this->links_trans = $this->path_links_trans . $file_links;
}
$this->changes_final = $this->path_changes_final . $file_changes;
$this->changes_trans = $this->path_changes_trans . $file_changes;
$this->oLogger->log($this->changes_final);
if ($this->use_links) {
$this->aFile_perms = array($this->path_schema_trans, $this->path_changes_final, $this->path_changes_trans, $this->path_links_trans, $this->links_final, $this->schema_final, MAX_SCHEMA_LOG, MAX_PATH . '/www/devel/');
} else {
$this->aFile_perms = array($this->path_schema_trans, $this->path_changes_final, $this->path_changes_trans, $this->schema_final, MAX_SCHEMA_LOG, MAX_PATH . '/www/devel/');
}
$this->aDump_options = array('output_mode' => 'file', 'output' => $this->schema_trans, 'end_of_line' => "\n", 'xsl_file' => "xsl/mdb2_schema.xsl", 'custom_tags' => array('version' => '', 'status' => 'transitional'));
$this->oSchema = MDB2_Schema::factory(OA_DB::singleton(OA_DB::getDsn()), $this->aDump_options);
$this->dd_file = 'etc/dd.generic.xml';
$this->aDD_definition = $this->oSchema->parseDictionaryDefinitionFile($this->dd_file);
ksort($this->aDD_definition);
//$this->aXMLRPCServer = array('path'=>'/upms/xmlrpc.php', 'host'=>'localhost','port'=>'80');
}
示例13: installSchema
/**
* Installs table(s)/data schema into database
*
* @access public
* @param string $new_schema New schema file path/name
* @param array $variables Schema variables
* @param string $old_schema Old schema file path/name
* @param string $init_data Schema is include initialization data
* @param string $create If the database should be created
* @return mixed True on success and Jaws_Error on failure
*/
function installSchema($new_schema, $variables = array(), $old_schema = false, $init_data = false, $create = true)
{
MDB2::loadFile('Schema');
$dsn = $this->_dsn;
unset($dsn['database']);
// If the database should be created
$variables['create'] = (int) $create;
// The database name
$variables['database'] = $this->_dsn['database'];
// Prefix of all the tables added
$variables['table_prefix'] = $this->getPrefix();
// set default charset
if (!isset($variables['charset'])) {
$variables['charset'] = $this->getUnicodeCharset();
}
$options = array('debug' => false, 'log_line_break' => '<br />', 'portability' => MDB2_PORTABILITY_ALL ^ MDB2_PORTABILITY_EMPTY_TO_NULL ^ MDB2_PORTABILITY_FIX_CASE ^ MDB2_PORTABILITY_RTRIM, 'quote_identifier' => true, 'force_defaults' => false);
switch ($this->_dsn['phptype']) {
case 'ibase':
$options['portability'] = $options['portability'] | MDB2_PORTABILITY_FIX_CASE;
$options['database_path'] = empty($this->_db_path) ? JAWS_DATA : $this->_db_path;
break;
case 'oci8':
$options['emulate_database'] = false;
$options['portability'] = $options['portability'] | MDB2_PORTABILITY_FIX_CASE;
break;
case 'sqlite':
$options['database_path'] = empty($this->_db_path) ? JAWS_DATA : $this->_db_path;
break;
case 'mssql':
$options['multibyte_text_field_type'] = $this->Is_FreeTDS_MSSQL_Driver();
break;
}
if ($this->_is_dba) {
$options['DBA_username'] = $this->_dsn['username'];
$options['DBA_password'] = $this->_dsn['password'];
}
if (!isset($this->schema)) {
$this->schema =& MDB2_Schema::factory($this->dbc, $options);
if (MDB2::isError($this->schema)) {
return $this->schema;
}
}
$method = $init_data === true ? 'writeInitialization' : 'updateDatabase';
$result = $this->schema->{$method}($new_schema, $old_schema, $variables);
if (MDB2::isError($result)) {
$this->schema->disconnect();
unset($this->schema);
$GLOBALS['log']->Log(JAWS_ERROR_ERROR, $result->getUserInfo(), 2);
return new Jaws_Error($result->getMessage(), $result->getCode(), JAWS_ERROR_ERROR, 1);
}
return $result;
}
示例14: doInit
/**
* Initializes a database with data
*
* @param array $args Command line arguments
*
* @return void
*/
protected function doInit($args)
{
list($typeSource, $dsnSource) = $this->getFileOrDsn($args);
list($typeDest, $dsnDest) = $this->getFileOrDsn($args);
if ($typeSource != 'file') {
throw new MDB2_Schema_Tool_ParameterException('Data must come from a source file');
}
if ($typeDest != 'dsn') {
throw new MDB2_Schema_Tool_ParameterException('A schema can only be loaded into a database, not a file');
}
$schemaDest = MDB2_Schema::factory($dsnDest, $this->getSchemaOptions());
$this->throwExceptionOnError($schemaDest, 'connecting to destination database');
$definition = $schemaDest->getDefinitionFromDatabase();
$this->throwExceptionOnError($definition, 'loading definition from database');
$op = $schemaDest->writeInitialization($dsnSource, $definition);
$this->throwExceptionOnError($op, 'initializing database');
}
示例15: die
$smarty->assign("site_url", "http://{$_SERVER['HTTP_HOST']}" . path::http());
$smarty->assign("site_root", path::http());
$smarty->assign("site_images", path::http("images"));
$smarty->assign("templates_abs", path::http("templates"));
$smarty->assign("page_title", $settings['site']['long_name']);
$dsn = $settings['dsn'];
require_once 'MDB2/Schema.php';
// Using include path (PEAR Class)
PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'handle_pear_error');
$db =& MDB2::connect($dsn);
// With PEAR::isError you can differentiate between an error or
// a valid connection.
if (PEAR::isError($db)) {
die;
}
$manager =& MDB2_Schema::factory($db);
$input_file = path::file("data") . "database/schema";
$schema_mod = $cache->get("schema_modified", 60 * 24);
if (!file_exists("{$input_file}.xml") || !$schema_mod || $schema_mod < filemtime("{$input_file}.xml")) {
$db_name = $manager->db->database_name;
if (!$manager->updateDatabase("{$input_file}.xml", "{$input_file}_current.xml", array('db_name' => $db_name, 'table_prefix' => $db_prefix))) {
die("Schema Update Error.");
}
$cache->set("schema_modified", filemtime("{$input_file}.xml"));
}
require_once path::file("classes") . "content_class.php";
$content = new content_handling();
require_once path::file("classes") . "page_handling_class.php";
$page_handler = new page_hander();
require_once path::file("classes") . "users_class.php";
// Initiate session handler class