Пример #1
0
function ddc_gentable_o($obj, $sql)
{
    $sa = new ddc_raw();
    foreach ($obj->cols as $e) {
        //		$sa->addcol($e['name'],$e['type'],$e['null'],$e['default'],$e['sequence'],$e['comment']);
        $sa->addcol($e['name'], $e['sql_type'], $e['sql_null'], $e['sql_default'], $e['sql_sequence'], $e['sql_comment']);
    }
    foreach ($obj->keys as $e) {
        //	function addcol_to_key($key,$name,$sub)
        $sa->addcol_to_key($e['key'], $e['name'], $e['sub']);
    }
    $sa->ctbl = $obj->name;
    if ($sql->query("SHOW COLUMNS FROM `" . $sql->esc($obj->name) . "`")) {
        $sb = new ddc_raw();
        $sb->load_table($obj->name, $sql);
        $sb->gen_changes($sa);
        $v = $sb->commit_changes($sql);
        if ($v) {
            print $v;
        }
    } else {
        $res = $sql->query($sa->create_query($obj->name));
        if (!$res) {
            die($sql->err());
        }
    }
}
Пример #2
0
print "<HTML>";
//$r=$sql->query("SHOW COLUMNS FROM `$testtbl`");
//var_dump($v1->cols);
$v1->print_cols();
$v1->print_keys();
//var_dump($v1->keys);
//$v1->delcol('doorname');$v1->delcol('fillmodel');$v1->delcol('filltype');
print $v1->create_query('test');
$v2 = new ddc_raw();
$v2->addcol('test', 'varchar(10)', 1, NULL, NULL, NULL);
$v2->addcol('test1', 'varchar(10)', 1, NULL, NULL, NULL);
$v2->addcol('test2', 'varchar(10)', 1, NULL, NULL, NULL);
$v2->addcol('test3', 'varchar(10)', 1, NULL, NULL, NULL);
$v2->addcol('id', 'int(10) unsigned auto_increment', 1, NULL, NULL, NULL);
$v2->addcol('doorname', 'varchar(10)', 1, NULL, NULL, NULL);
$v2->addcol_to_key('PRIMARY', 'id', NULL);
$v2->addcol_to_key('PRIMARY', 'test', 5);
$v1->gen_changes($v2);
$v1->print_querys();
$r = $v1->commit_changes($sql);
if ($r) {
    echo $r;
}
print "Script processing took " . (microtime(true) - $profiler) . " sec<br>";
print $sql->qcnt . ' querys, took ' . $sql->querytime . ' sec';
print '<table border=1>';
print "<tr><td colspan=2>1</td><td rowspan=2>2</td></tr>";
print "<tr><td rowspan=2>3</td><td>4</td></tr>";
print "<tr><td colspan=2>5</td></tr>";
print '</table>';
print "</HTML>";