本文整理汇总了PHP中adoSchema::ParseSchema方法的典型用法代码示例。如果您正苦于以下问题:PHP adoSchema::ParseSchema方法的具体用法?PHP adoSchema::ParseSchema怎么用?PHP adoSchema::ParseSchema使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类adoSchema
的用法示例。
在下文中一共展示了adoSchema::ParseSchema方法的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);
}
示例2: 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;
}
}
示例3: 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;
}
示例4: ADONewConnection
// To build the schema, start by creating a normal ADOdb connection:
$db = ADONewConnection('mysql');
$db->Connect('localhost', 'root', '', 'test') || die('fail connect1');
// 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");
var_dump($sql);
print "</pre>\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();
print "<b>SQL to build xmlschema-mssql.xml</b>:\n<pre>";
$db2 = ADONewConnection('mssql');
$db2->Connect('', 'adodb', 'natsoft', 'northwind') || die("Fail 2");
$db2->Execute("drop table simple_table");
$schema = new adoSchema($db2);
$sql = $schema->ParseSchema("xmlschema-mssql.xml");
print_r($sql);
print "</pre>\n";
$db2->debug = 1;
foreach ($sql as $s) {
$db2->Execute($s);
}
示例5: printmsg
// Build the SQL array from the schema XML file
$sql = $schema->ParseSchema($xmlfile_tables);
// Execute the SQL on the database
if ($schema->ExecuteSchema($sql) == 2) {
$text .= "<img src=\"{$images}/silk/accept.png\" border=\"0\" /> Creating and updating tables within database '{$database_name}'.<br>";
printmsg("INFO => Creating and updating tables within new DB: {$database_name}", 0);
} else {
$status++;
$text .= "<img src=\"{$images}/silk/exclamation.png\" border=\"0\" /> There was an error processing tables.<br><span style='font-size: xx-small;'>" . $db->ErrorMsg() . "</span><br>";
printmsg("ERROR => There was an error processing tables: " . $db->ErrorMsg(), 0);
}
// Load initial data into the new tables
if ($status == 0) {
$schema = new adoSchema($db);
// Build the SQL array from the schema XML file
$sql = $schema->ParseSchema($xmlfile_data);
//$text .= "<pre>".$schema->PrintSQL('TEXT')."</pre>";
// Execute the SQL on the database
if ($schema->ExecuteSchema($sql) == 2) {
$text .= "<img src=\"{$images}/silk/accept.png\" border=\"0\" /> Loaded tables with default data.<br>";
printmsg("INFO => Loaded data to new DB: {$database_name}", 0);
} else {
$status++;
$text .= "<img src=\"{$images}/silk/exclamation.png\" border=\"0\" /> Failed load default data.<br><span style='font-size: xx-small;'>" . $db->ErrorMsg() . "</span><br>";
printmsg("ERROR => There was an error loading the data: " . $db->ErrorMsg(), 0);
}
}
// Add the system user to the database
// Run the query
if ($status == 0) {
// it is likely that this method here is mysql only?
示例6: adoSchema
//Reconnect. Hrmm, this is kinda weird.
$db->Connect($db_host, $db_user, $db_password, $db_name);
}
}
break;
default:
echo_normal("Sorry, <b>setup.php</b> currently does not fully support \"<b>{$db_type}</b>\" databases.\n\t\t\t\t\t<br>I'm assuming you've already created the database \"{$db_name}\", attempting to create tables.\n\t\t\t\t\t<br> Please email <b>{$author_email}</b> code to detect if a database is created or not so full support for \"<b>{$db_type}</b>\" can be added.");
}
/*
* Attempt to create tables
*/
// Create the schema object and build the query array.
$schema = new adoSchema($db);
$schema->SetPrefix($db_table_prefix);
// Build the SQL array
$schema->ParseSchema('schema.xml');
// maybe display this if $gacl->debug is true?
if ($gacl->_debug) {
print "Here's the SQL to do the build:<br />\n<code>";
print $schema->getSQL('html');
print "</code>\n";
// exit;
}
// Execute the SQL on the database
#ADODB's xmlschema is being lame, continue on error.
$schema->ContinueOnError(TRUE);
$result = $schema->ExecuteSchema();
if ($result != 2) {
echo_failed('Failed creating tables. Please enable DEBUG mode (set it to TRUE in $gacl_options near top of admin/gacl_admin.inc.php) to see the error and try again. You will most likely need to delete any tables already created.');
}
if ($failed <= 0) {
示例7: htmlspecialchars
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";
}
// Finally, clean up after the XML parser
// (PHP won't do this for you!)
//$schema->Destroy();
print "<pre><hr>\n";
foreach ($sql as $s) {
echo "\$db2->Execute(\"{$s}\");<br><br>";
示例8: adoSchema
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Retrospect-GDS - Installation</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="install.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>Retrospect-GDS Installer</h1>
<h2>Step 4 - Upgrading Tables</h2>
<?php
# update tables and indexes
$schema = new adoSchema($db);
$schema->setPrefix($g_db_prefix);
$sql = $schema->ParseSchema('upgrade.xml');
$result = $schema->ExecuteSchema($sql);
$error = $db->ErrorMsg();
if ($result != true) {
die('The following error was encountered while creating the database tables:<br/> ' . $error);
} else {
echo 'No error were encountered.';
}
?>
<h2>Step 5 - Updating Records</h2>
<?php
$upgrader = new Upgrader();
$upgrader->upgrade_languages();
示例9: adoSchema
$db->Connect($db_host, $db_user, $db_password, $db_name);
}
}
break;
default:
echo_normal("Sorry, <b>setup.php</b> currently does not fully support \"<b>{$db_type}</b>\" databases.\n\t\t\t\t\t<br>I'm assuming you've already created the database \"{$db_name}\", attempting to create tables.\n\t\t\t\t\t<br> Please email <b>{$author_email}</b> code to detect if a database is created or not so full support for \"<b>{$db_type}</b>\" can be added.");
}
/*
* Attempt to create tables
*/
// Create the schema object and build the query array.
$schema = new adoSchema($db);
$schema->SetPrefix($db_table_prefix, FALSE);
//set $underscore == FALSE
// Build the SQL array
$schema->ParseSchema(dirname(__FILE__) . '/schema.xml');
// maybe display this if $gacl->debug is true?
if ($gacl->_debug) {
print "Here's the SQL to do the build:<br />\n<code>";
print $schema->getSQL('html');
print "</code>\n";
// exit;
}
// Execute the SQL on the database
#ADODB's xmlschema is being lame, continue on error.
$schema->ContinueOnError(TRUE);
$result = $schema->ExecuteSchema();
if ($result != 2) {
echo_failed('Failed creating tables. Please enable DEBUG mode (set it to TRUE in $gacl_options near top of admin/gacl_admin.inc.php) to see the error and try again. You will most likely need to delete any tables already created.');
}
if ($failed <= 0) {
示例10: adoSchema
$db->Connect($db_host, $db_user, $db_password, $db_name);
}
}
break;
default:
echo_normal("Sorry, <b>setup.php</b> currently does not fully support \"<b>{$db_type}</b>\" databases.\n\t\t\t\t\t<br>I'm assuming you've already created the database \"{$db_name}\", attempting to create tables.\n\t\t\t\t\t<br> Please email <b>{$author_email}</b> code to detect if a database is created or not so full support for \"<b>{$db_type}</b>\" can be added.");
}
/*
* Attempt to create tables
*/
// Create the schema object and build the query array.
$schema = new adoSchema($db);
$schema->SetPrefix($db_table_prefix, FALSE);
//set $underscore == FALSE
// Build the SQL array
$schema->ParseSchema(AMP_BASE_INCLUDE_PATH . 'phpgacl/schema.xml');
// maybe display this if $gacl->debug is true?
//if ($gacl->_debug) {
print "Here's the SQL to do the build:<br />\n<code>";
print $schema->getSQL('html');
print "</code>\n";
// exit;
//}
// Execute the SQL on the database
#ADODB's xmlschema is being lame, continue on error.
$schema->ContinueOnError(TRUE);
$result = $schema->ExecuteSchema();
if ($result != 2) {
echo_failed('Failed creating tables. Please enable DEBUG mode (set it to TRUE in $gacl_options near top of admin/gacl_admin.inc.php) to see the error and try again. You will most likely need to delete any tables already created.');
}
if ($failed <= 0) {
示例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;
}
示例12: die
$result = $schema->ExecuteSchema($sql);
$schema->Destroy();
if ($result != true) {
die('The existing tables could not be dropped. Please remove all Retrospect-GDS tables and try again.');
} else {
echo 'No error were encountered.';
}
?>
<h2>Step 5 - Creating Tables</h2>
<?php
# create new tables and indexes
$schema = new adoSchema($db);
$schema->setPrefix($g_db_prefix);
$sql = $schema->ParseSchema('create.xml');
$result = $schema->ExecuteSchema($sql);
$error = $db->ErrorMsg();
if ($result != true) {
die('The following error was encountered while creating the database tables:<br/> ' . $error);
} else {
echo 'No error were encountered.';
}
?>
<h2>Step 6 - Verifying data</h2>
<?php
# Verifying tables
$tables_in_db = $db->MetaTables('TABLES');
示例13: 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();
示例14: 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;
}
$this->checkConnection();
$db = $this->database;
$schema = new adoSchema($db);
//Debug Adodb XML Schema
$schema->XMLS_DEBUG = TRUE;
//Debug Adodb
$schema->debug = true;
$sql = $schema->ParseSchema($schemaFile);
$this->println("--------------Starting the table creation------------------");
$result = $schema->ExecuteSchema($sql, $this->continueInstallOnError);
if ($result) {
print $db->errorMsg();
}
// needs to return in a decent way
$this->println("ADODB createTables " . $schemaFile . " status=" . $result);
return $result;
}
示例15: setupDDBB
function setupDDBB()
{
require_once $this->adodb_path . '/adodb.inc.php';
require_once $this->adodb_path . '/adodb-xmlschema.inc.php';
$bol_error = true;
$int = 1;
do {
$SGBDs = $this->getAllSGBD();
$select = $this->cli->prompt(agt('ddbbSGBD'), $SGBDs);
$platform = $SGBDs[$select];
$dbHost = $this->cli->prompt(agt('ddbbHost') . ': ');
$dbUser = $this->cli->prompt(agt('ddbbUser') . ': ');
$dbPassword = $this->cli->prompt(agt('ddbbPasswd') . ': ');
$dbName = $this->cli->prompt(agt('ddbbName') . ': ');
$db = ADONewConnection($platform);
$db->Connect($dbHost, $dbUser, $dbPassword, $dbName);
if (is_resource($db->_connectionID)) {
$this->log(agt('ddbbConnOk'), 'success');
$bol_error = false;
break;
} else {
$this->log(agt('ddbbConnErr'), 'error');
}
$int++;
} while ($int < 4);
if ($bol_error) {
return false;
}
$allDDBB = $db->MetaDatabases();
if (!empty($allDDBB)) {
if (in_array($dbName, $allDDBB)) {
$this->log(agt('ddbbNameOk'), 'success');
} else {
$this->log(agt('ddbbNameErr'), 'warning');
$this->log(agt('ddbbCreate'), 'warning');
if (!$db->Execute("create database {$dbName}")) {
$this->cli->fatal(agt('ddbbCreateErr'));
} else {
$this->log(agt('ddbbCreateOk'), 'success');
//Reconectamos
$db->Connect($dbHost, $dbUser, $dbPassword, $dbName);
}
}
}
$schemaFile = $this->miguel_path . '/' . $this->miguel_name . '/modules/common/include/miguel_schema.xml';
if (file_exists($schemaFile)) {
//Preparamos el proceso de creación de la BBDD
$schema = new adoSchema($db);
$sql = $schema->ParseSchema($schemaFile);
$result = $schema->ExecuteSchema($sql, true);
if ($result != 2) {
$this->cli->fatal(agt('ddbbTableErr'));
}
$this->log(agt('ddbbTableOk'), 'success');
} else {
$this->cli->fatal(agt('fsErr'));
}
return true;
}