adoSchema::getSQL PHP Method

getSQL() public method

Gets the SQL array in the specified format.
public getSQL ( string $format = NULL, $sqlArray = NULL ) : mixed
$format string Format
return mixed SQL
    function getSQL($format = NULL, $sqlArray = NULL)
    {
        if (!is_array($sqlArray)) {
            $sqlArray = $this->sqlArray;
        }
        if (!is_array($sqlArray)) {
            return FALSE;
        }
        switch (strtolower($format)) {
            case 'string':
            case 'text':
                return !empty($sqlArray) ? implode(";\n\n", $sqlArray) . ';' : '';
            case 'html':
                return !empty($sqlArray) ? nl2br(htmlentities(implode(";\n\n", $sqlArray) . ';')) : '';
        }
        return $this->sqlArray;
    }

Usage Example

Esempio n. 1
0
        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) {
    echo_success('
Installation Successful!!!
<div align="center">
<font color="red"><b>*IMPORTANT*</b></font><br/>