当前位置: 首页>>代码示例>>PHP>>正文


PHP adoSchema类代码示例

本文整理汇总了PHP中adoSchema的典型用法代码示例。如果您正苦于以下问题:PHP adoSchema类的具体用法?PHP adoSchema怎么用?PHP adoSchema使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了adoSchema类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: create_table

function create_table($schemaFile, $prefix, $db, $drop = true)
{
    $result = array();
    $schema = new adoSchema($db);
    $schema->setPrefix($prefix);
    $sql = $schema->ParseSchema($schemaFile);
    $dbTable = $schema->obj;
    $adoDB = $schema->db;
    $stmt = sprintf($adoDB->_dropSeqSQL, $dbTable->name);
    $dropresult = true;
    if ($drop) {
        $ok = $db->Execute($stmt);
        if (!$ok) {
            $dropresult = false;
        }
        $schema = new adoSchema($db);
        $schema->setPrefix($prefix);
        $sql = $schema->ParseSchema($schemaFile);
    }
    $result = $schema->ExecuteSchema($sql);
    ob_start();
    print_r($sql);
    $sql_r = ob_get_contents();
    ob_end_clean();
    return array('result' => $result, 'sql' => $sql_r);
}
开发者ID:umbecr,项目名称:camilaframework,代码行数:26,代码来源:schema.inc.php

示例2: execute

 /**
  * Parse an XML database file and output the corresponding SQL statements.
  * See lib/pkp/dtd/xmlSchema.dtd for the format of the XML files.
  */
 function execute()
 {
     require_once './lib/pkp/lib/adodb/adodb-xmlschema.inc.php';
     if (in_array($this->command, array('print', 'save'))) {
         // Don't connect to actual database (so parser won't build upgrade XML)
         $conn = new DBConnection(Config::getVar('database', 'driver'), null, null, null, null, true, Config::getVar('i18n', 'connection_charset'));
         $dbconn = $conn->getDBConn();
     } else {
         // Create or upgrade existing database
         $dbconn =& DBConnection::getConn();
     }
     $schema = new adoSchema($dbconn);
     $dict =& $schema->dict;
     $dict->SetCharSet(Config::getVar('i18n', 'database_charset'));
     if ($this->type == 'schema') {
         // Parse XML schema files
         $sql = $schema->parseSchema($this->inputFile);
         switch ($this->command) {
             case 'execute':
                 $schema->ExecuteSchema();
                 break;
             case 'save':
             case 'save_upgrade':
                 $schema->SaveSQL($this->outputFile);
                 break;
             case 'print':
             case 'print_upgrade':
             default:
                 echo @$schema->PrintSQL('TEXT') . "\n";
                 break;
         }
     } else {
         if ($this->type == 'data') {
             // Parse XML data files
             $dataXMLParser = new DBDataXMLParser();
             $dataXMLParser->setDBConn($dbconn);
             $sql = $dataXMLParser->parseData($this->inputFile);
             switch ($this->command) {
                 case 'execute':
                     $schema->addSQL($sql);
                     $schema->ExecuteSchema();
                     break;
                 case 'save':
                 case 'save_upgrade':
                     $schema->addSQL($sql);
                     $schema->SaveSQL($this->outputFile);
                     break;
                 case 'print':
                 case 'print_upgrade':
                 default:
                     $schema->addSQL($sql);
                     echo @$schema->PrintSQL('TEXT') . "\n";
                     break;
             }
             $schema->destroy();
             $dataXMLParser->destroy();
         }
     }
 }
开发者ID:farhanabbas1983,项目名称:ojs-1,代码行数:63,代码来源:XmlToSqlTool.inc.php

示例3: GetTableCreationSQL

/**
 * Generates the SQL commands necessary to create all tables
 * @param string $db_type Database type for which to generate SQL 
 * @return array Array of SQL commands or false if error
 */
function GetTableCreationSQL($db_type, $tbl_prefix)
{
    $db = NewAdoConnection($db_type);
    $schema = new adoSchema($db);
    $schema->setPrefix($tbl_prefix);
    if ($sql = $schema->ParseSchema('create.xml')) {
        return $sql;
    } else {
        return false;
    }
}
开发者ID:guzzisto,项目名称:retrospect-gds,代码行数:16,代码来源:generate_sql.php

示例4: perform

 function perform()
 {
     if (empty($this->loop)) {
         $this->loop = 1;
     }
     if ($this->prepareParameters() === FALSE) {
         $this->result = INSTALLER_ACTION_FAIL;
         return $this->result;
     }
     if (!is_readable($this->schema_file)) {
         $this->result = INSTALLER_ACTION_FAIL;
         $this->result_message = "Could not read file sql {$this->schema_file}.";
         $this->loop = 2;
         return $this->result;
     }
     # Connect to the DB
     $db = $this->connect();
     if ($db === FALSE) {
         return $this->result;
     }
     # Create empty ADOdb connection
     $conn = ADONewConnection($this->type);
     # Create new ADO Schema object
     $schema = new adoSchema($conn);
     # Build the SQL query from the Schema file
     $sql = $schema->ParseSchema($this->schema_file);
     # Execute the SQL query
     # "2" is status returned by ExecuteSQLArray()
     $dict = NewDataDictionary($db);
     @($ok = 2 == $dict->ExecuteSQLArray($sql, FALSE));
     if ($ok) {
         $this->result = INSTALLER_ACTION_SUCCESS;
         $this->result_message = "DB schema loaded successfully";
         $this->loop = 3;
     } else {
         $this->result = INSTALLER_ACTION_FAIL;
         $this->result_message = "Errors on execution of the schema SQL: " . $db->ErrorMsg();
         $this->loop = 2;
     }
     return $this->result;
 }
开发者ID:patmark,项目名称:care2x-tz,代码行数:41,代码来源:SQLSchema.php

示例5: NewADOConnection

<?php

require '../adodb/adodb5/adodb.inc.php';
require '../adodb/adodb5/adodb-xmlschema.inc.php';
$_server = "IMAGESERVER,1433";
$_dbServer = "3170-090204";
$_dbServer = "disney-live";
$_dbUsername = "sa";
$_dbPassword = "1mage";
$dsn = "Driver={SQL Server};Server=" . $_server . ";Database=" . $_dbServer . ";";
$db =& NewADOConnection('odbc_mssql');
$db->Connect($dsn, $_dbUsername, $_dbPassword);
$dict = NewDataDictionary($db);
$schema = new adoSchema($db);
$ext = $schema->ExtractSchema(true);
//print_r($ext); die;
开发者ID:roycocup,项目名称:Tests,代码行数:16,代码来源:index.php

示例6: adodb_session_create_table

function adodb_session_create_table($schemaFile = null, $conn = null)
{
    // set default values
    if ($schemaFile === null) {
        $schemaFile = ADODB_SESSION . '/session_schema.xml';
    }
    if ($conn === null) {
        $conn =& ADODB_Session::_conn();
    }
    if (!$conn) {
        return 0;
    }
    $schema = new adoSchema($conn);
    $schema->ParseSchema($schemaFile);
    return $schema->ExecuteSchema();
}
开发者ID:amjadtbssm,项目名称:website,代码行数:16,代码来源:adodb-session.php

示例7: executeAction

 /**
  * Execute a single installer action.
  * @param $action array
  * @return boolean
  */
 function executeAction($action)
 {
     switch ($action['type']) {
         case 'schema':
             $fileName = $action['file'];
             $this->log(sprintf('schema: %s', $action['file']));
             require_once './lib/pkp/lib/adodb/adodb-xmlschema.inc.php';
             $schemaXMLParser = new adoSchema($this->dbconn);
             $dict =& $schemaXMLParser->dict;
             $dict->SetCharSet($this->dbconn->charSet);
             $sql = $schemaXMLParser->parseSchema($fileName);
             $schemaXMLParser->destroy();
             if ($sql) {
                 return $this->executeSQL($sql);
             } else {
                 $this->setError(INSTALLER_ERROR_DB, str_replace('{$file}', $fileName, __('installer.installParseDBFileError')));
                 return false;
             }
             break;
         case 'data':
             $fileName = $action['file'];
             $condition = isset($action['attr']['condition']) ? $action['attr']['condition'] : null;
             $includeAction = true;
             if ($condition) {
                 $funcName = create_function('$installer,$action', $condition);
                 $includeAction = $funcName($this, $action);
             }
             $this->log('data: ' . $action['file'] . ($includeAction ? '' : ' (skipped)'));
             if (!$includeAction) {
                 break;
             }
             $sql = $this->dataXMLParser->parseData($fileName);
             // We might get an empty SQL if the upgrade script has
             // been executed before.
             if ($sql) {
                 return $this->executeSQL($sql);
             }
             break;
         case 'code':
             $condition = isset($action['attr']['condition']) ? $action['attr']['condition'] : null;
             $includeAction = true;
             if ($condition) {
                 $funcName = create_function('$installer,$action', $condition);
                 $includeAction = $funcName($this, $action);
             }
             $this->log(sprintf('code: %s %s::%s' . ($includeAction ? '' : ' (skipped)'), isset($action['file']) ? $action['file'] : 'Installer', isset($action['attr']['class']) ? $action['attr']['class'] : 'Installer', $action['attr']['function']));
             if (!$includeAction) {
                 return true;
             }
             // Condition not met; skip the action.
             if (isset($action['file'])) {
                 require_once $action['file'];
             }
             if (isset($action['attr']['class'])) {
                 return call_user_func(array($action['attr']['class'], $action['attr']['function']), $this, $action['attr']);
             } else {
                 return call_user_func(array(&$this, $action['attr']['function']), $this, $action['attr']);
             }
             break;
         case 'note':
             $condition = isset($action['attr']['condition']) ? $action['attr']['condition'] : null;
             $includeAction = true;
             if ($condition) {
                 $funcName = create_function('$installer,$action', $condition);
                 $includeAction = $funcName($this, $action);
             }
             if (!$includeAction) {
                 break;
             }
             $this->log(sprintf('note: %s', $action['file']));
             $this->notes[] = join('', file($action['file']));
             break;
     }
     return true;
 }
开发者ID:EreminDm,项目名称:water-cao,代码行数:80,代码来源:Installer.inc.php

示例8: updateSchema

 /**
  * Called during the install process to install the plugin schema,
  * if applicable.
  * @param $hookName string
  * @param $args array
  * @return boolean
  */
 function updateSchema($hookName, $args)
 {
     $installer =& $args[0];
     $result =& $args[1];
     $schemaXMLParser = new adoSchema($installer->dbconn);
     $dict =& $schemaXMLParser->dict;
     $dict->SetCharSet($installer->dbconn->charSet);
     $sql = $schemaXMLParser->parseSchema($this->getInstallSchemaFile());
     if ($sql) {
         $result = $installer->executeSQL($sql);
     } else {
         $installer->setError(INSTALLER_ERROR_DB, str_replace('{$file}', $this->getInstallSchemaFile(), __('installer.installParseDBFileError')));
         $result = false;
     }
     return false;
 }
开发者ID:sedici,项目名称:ocs,代码行数:23,代码来源:PKPPlugin.inc.php

示例9: printmsg

                    $status++;
                    $text .= "<img src=\"{$images}/silk/exclamation.png\" border=\"0\" /> Failed to create system user '{$sys_login}'.<br><span style='font-size: xx-small;'>" . $db->ErrorMsg() . "</span><br>";
                    printmsg("ERROR => There was an error creating DB user: " . $db->ErrorMsg(), 0);
                }
                // add the default domain to the system
                // This is a manual add with hard coded values for timers.
                $xmldefdomain = <<<EOL
<?xml version="1.0"?>
<schema version="0.3">
<sql>
    <query>INSERT INTO domains (id,name,admin_email,default_ttl,refresh,retry,expiry,minimum) VALUES (1,'{$default_domain}','hostmaster', 86400, 86400, 3600, 3600, 3600)</query>
    <query>UPDATE sys_config SET value='{$default_domain}' WHERE name like 'dns_defaultdomain'</query>
</sql>
</schema>
EOL;
                $schema = new adoSchema($db);
                // Build the SQL array from the schema XML file
                $domainsql = $schema->ParseSchemaString($xmldefdomain);
                // Execute the SQL on the database
                if ($schema->ExecuteSchema($domainsql) == 2) {
                    $text .= "<img src=\"{$images}/silk/accept.png\" border=\"0\" /> Created default DNS domain '{$default_domain}'.<br>";
                } else {
                    $status++;
                    $text .= "<img src=\"{$images}/silk/exclamation.png\" border=\"0\" /> Failed to create default DNS domain '{$default_domain}'.<br><span style='font-size: xx-small;'>" . $db->ErrorMsg() . "</span><br>";
                }
                // Open the database config and write the contents to it.
                if (!($fh = @fopen($dbconffile, 'w'))) {
                    $status++;
                    $text .= "<img src=\"{$images}/silk/exclamation.png\" border=\"0\" /> Failed to open config file for writing: '{$dbconffile}'.<br>";
                } else {
                    fwrite($fh, "<?php\n\n\$ona_contexts=" . var_export($ona_contexts, TRUE) . ";\n\n?>");
开发者ID:edt82,项目名称:ona,代码行数:31,代码来源:install.php

示例10: execute_upgrade_file

function execute_upgrade_file($folder, $installed_version)
{
    global $db, $page, $conf;
    // At first the config file
    $upgrade_path = BASEDIR . '/upgrade/' . $folder;
    new ConfUpdater(CONFIG_PATH, $upgrade_path);
    $upgrade_info = parse_ini_file($upgrade_path . '/upgrade.info', true);
    // dev version upgrade?
    if ($folder == Flyspray::base_version($installed_version)) {
        $type = 'develupgrade';
    } else {
        $type = 'defaultupgrade';
    }
    // Next a mix of XML schema files and PHP upgrade scripts
    if (!isset($upgrade_info[$type])) {
        die('#1 Bad upgrade.info file.');
    }
    ksort($upgrade_info[$type]);
    foreach ($upgrade_info[$type] as $file) {
        if (substr($file, -4) == '.php') {
            require_once $upgrade_path . '/' . $file;
        }
        if (substr($file, -4) == '.xml') {
            $schema = new adoSchema($db->dblink);
            $xml = file_get_contents($upgrade_path . '/' . $file);
            // $xml = str_replace('<table name="', '<table name="' . $conf['database']['dbprefix'], $xml);
            // Set the prefix for database objects ( before parsing)
            $schema->setPrefix($conf['database']['dbprefix'], false);
            $schema->ParseSchemaString($xml);
            $schema->ExecuteSchema(null, true);
        }
    }
    // Last but not least global prefs update
    if (isset($upgrade_info['fsprefs'])) {
        $sql = $db->Query('SELECT pref_name FROM {prefs}');
        $existing = $db->FetchCol($sql);
        // Add what is missing
        foreach ($upgrade_info['fsprefs'] as $name => $value) {
            if (!in_array($name, $existing)) {
                $db->Query('INSERT INTO {prefs} (pref_name, pref_value) VALUES (?, ?)', array($name, $value));
            }
        }
        // Delete what is too much
        foreach ($existing as $name) {
            if (!isset($upgrade_info['fsprefs'][$name])) {
                $db->Query('DELETE FROM {prefs} WHERE pref_name = ?', array($name));
            }
        }
    }
    $db->Query('UPDATE {prefs} SET pref_value = ? WHERE pref_name = ?', array(basename($upgrade_path), 'fs_ver'));
    #$page->assign('done', true);
    return "Write " . basename($upgrade_path) . " into table {prefs} fs_ver in database";
}
开发者ID:canneverbe,项目名称:flyspray,代码行数:53,代码来源:upgrade.php

示例11: createTables

 function createTables($schemaFile, $dbHostName = false, $userName = false, $userPassword = false, $dbName = false, $dbType = false)
 {
     $this->println("ADODB createTables " . $schemaFile);
     if ($dbHostName != false) {
         $this->dbHostName = $dbHostName;
     }
     if ($userName != false) {
         $this->userName = $userPassword;
     }
     if ($userPassword != false) {
         $this->userPassword = $userPassword;
     }
     if ($dbName != false) {
         $this->dbName = $dbName;
     }
     if ($dbType != false) {
         $this->dbType = $dbType;
     }
     //$db = ADONewConnection($this->dbType);
     $this->checkConnection();
     $db = $this->database;
     //$db->debug = true;
     //$this->println("ADODB createTables connect status=".$db->Connect($this->dbHostName, $this->userName, $this->userPassword, $this->dbName));
     $schema = new adoSchema($db);
     //Debug Adodb XML Schema
     $sehema->XMLS_DEBUG = TRUE;
     //Debug Adodb
     $sehema->debug = true;
     $sql = $schema->ParseSchema($schemaFile);
     $this->println("--------------Starting the table creation------------------");
     //$this->println($sql);
     //integer ExecuteSchema ([array $sqlArray = NULL], [boolean $continueOnErr = NULL])
     $result = $schema->ExecuteSchema($sql, $this->continueInstallOnError);
     //if($result) print $db->errorMsg();
     $this->println("ADODB createTables error: " . $db->errorMsg());
     // needs to return in a decent way
     $this->println("ADODB createTables " . $schemaFile . " status=" . $result);
     return $result;
 }
开发者ID:honj51,项目名称:taobaocrm,代码行数:39,代码来源:PearDatabase.php

示例12: error_reporting

<?php

error_reporting(E_ALL);
die('Enable me by commenting this out by editing ' . basename(__FILE__) . ' at line ' . __LINE__);
require_once '../vendor/adodb/adodb-php/adodb.inc.php';
require_once '../vendor/adodb/adodb-php/adodb-xmlschema03.inc.php';
$conf = @parse_ini_file('../flyspray.conf.php', true) or die('Cannot open config file.');
/* Start by creating a normal ADODB connection. */
$db = ADONewConnection($conf['database']['dbtype']);
$db->Connect($conf['database']['dbhost'], $conf['database']['dbuser'], $conf['database']['dbpass'], $conf['database']['dbname']) or die('Cannot connect to DB.');
$db->debug = true;
/* Use the database connection to create a new adoSchema object. */
$schema = new adoSchema($db);
$withdata = false;
$stripprefix = true;
$data = $schema->ExtractSchema($withdata, '  ', $conf['database']['dbprefix'], $stripprefix);
file_put_contents('flyspray-schema.xml', $data);
开发者ID:canneverbe,项目名称:flyspray,代码行数:17,代码来源:exportdb.php

示例13: extractSchema

 function extractSchema()
 {
     $schema = new adoSchema($this->db);
     return $schema->extractSchema();
 }
开发者ID:uzerpllp,项目名称:uzerp,代码行数:5,代码来源:DB.php

示例14: ADONewConnection

<?php

require "path_to_adodb/adodb-xmlschema.inc.php";
// To build the schema, start by creating a normal ADOdb connection:
$db = ADONewConnection('mysql');
$db->Connect('localhost', 'someuser', '', 'schematest');
// Create the schema object and build the query array.
$schema = new adoSchema($db);
// Build the SQL array
$sql = $schema->ParseSchema("example.xml");
print "Here's the SQL to do the build:\n";
print_r($sql);
print "\n";
// Execute the SQL on the database
$result = $schema->ExecuteSchema($sql);
// Finally, clean up after the XML parser
// (PHP won't do this for you!)
$schema->Destroy();
开发者ID:BackupTheBerlios,项目名称:tulipan-svn,代码行数:18,代码来源:example.php

示例15: file

    <td colspan="2" valign="top">
<?php 
    include_once "../adodb-xmlschema.inc.php";
    echo "<h1>Test XML Schema</h1>";
    $ff = file('xmlschema.xml');
    echo "<pre>";
    foreach ($ff as $xml) {
        echo htmlspecialchars($xml);
    }
    echo "</pre>";
    $db = NewADOConnection('mysql', "pear");
    if ($_POST['create_test']) {
        $db->Connect($_POST['dbhost'], $_POST['dbusername'], $_POST['dbpassword'], $_POST['databasename']);
    }
    // To create a schema object and build the query array.
    $schema = new adoSchema($db);
    // To upgrade an existing schema object, use the following
    // To upgrade an existing database to the provided schema,
    // uncomment the following line:
    #$schema->upgradeSchema();
    print "<b>SQL to build xmlschema.xml</b>:\n<pre>";
    // Build the SQL array
    $sql = $schema->ParseSchema("xmlschema.xml");
    print_r($sql);
    print "</pre>\n";
    // Execute the SQL on the database
    $db->debug = true;
    if ($_POST['create_test']) {
        print "<pre><hr>\n";
        $result = $schema->ExecuteSchema($sql);
        print "</pre>\n";
开发者ID:briandodson,项目名称:bdcms,代码行数:31,代码来源:test_datadictionary.php


注:本文中的adoSchema类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。