adoSchema::ExecuteSchema PHP Method

ExecuteSchema() public method

Call this method to apply the current schema (generally created by calling ParseSchema() or ParseSchemaString() ) to the database (creating the tables, indexes, and executing other SQL specified in the schema) after parsing.
public ExecuteSchema ( array $sqlArray = NULL, boolean $continueOnErr = NULL )
$sqlArray array Array of SQL statements that will be applied rather than the current schema.
$continueOnErr boolean Continue to apply the schema even if an error occurs.
    function ExecuteSchema($sqlArray = NULL, $continueOnErr = NULL)
    {
        if (!is_bool($continueOnErr)) {
            $continueOnErr = $this->ContinueOnError();
        }
        if (!isset($sqlArray)) {
            $sqlArray = $this->sqlArray;
        }
        if (!is_array($sqlArray)) {
            $this->success = 0;
        } else {
            $this->success = $this->dict->ExecuteSQLArray($sqlArray, $continueOnErr);
        }
        return $this->success;
    }

Usage Example

示例#1
0
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);
}
All Usage Examples Of adoSchema::ExecuteSchema