PHP 4



         

MySQL - 7


if(!eregi("not null",$v)) $Fields[$k]=$v." not null";

$Fields=array("id"=>"int auto_increment primary key")

+$Fields+array(DataField=>"mediumblob");

}

Def0($Index,array());

//

$this->Fields=array(DataField=>"mediumblob");

$Data=$this->TableGetResult(

mysql_query("select ".DataField." from $Name where id=1")

);

// , .

// ,

// , , .

if(@is_array($Data)) {

if(!is_array($Fields)) {

$this->Error="Couldn't create table: no fields specified";

return;

}

Def0($Data["Fields"],array());

Def0($Data["Index"],array());

//** , - . alter table.

//1. ?

$Lst=array();

foreach($Fields as $k=>$v) {

if(!isSet($Data["Fields"][$k])) $Lst[]="add $k $v";

else if($Data["Fields"][$k]!=$v) $Lst[]="change $k $k $v";

}

//2. ?

foreach($Data["Fields"] as $k=>$v)

if(!isSet($Fields[$k])) $Lst[]="drop $k";

//3. ?

foreach($Index as $k=>$v) if(!isSet($Data["Index"][$k]))

$Lst[]="add index index_$k ($k".($v!=0?" ($v)":"").")";

//4. ?

foreach($Data["Index"] as $k=>$v)

if(!isSet($Index[$k])) $Lst[]="drop index index_$k";

if(count($Lst)) {

PrintDump($Lst);

if(!mysql_query("alter table $Name ".implode($Lst,","))) {

$this->Error=mysql_error();

return;

}

$Changed=1;

}

$this->JustCreated=0;

} else {

// .

// BugFix by DM:

// Error,