<?PHP$DBI=NewDbmysql;$DBI->DBH = ' Mysql://root:[email protected]/coffeetest ';$map=Array();$DBI->fetchmap ("SHOW TABLES",$map);$tables=Array_keys($map);//Find tables containing CID fields$cid _tables=Array(); for($j= 0;$j<Count($tables);$j++){ $map=Array(); $DBI->fetchmap ("DESCRIBE").$tables[$j],$map); foreach($map as $k=$v){ if($k= = ' CID ') { $cid _tables[] =$tables[$j]; } }}//find the Cid=0 data and fix$cid= 1;$cid 0_tables=Array(); for($j= 0;$j<Count($cid _tables);$j++){ $sql= "Select COUNT (*) from".$cid _tables[$j]." WHERE cid = 0 "; $count=$DBI->getval ($sql, 0); if($count>0)$cid 0_tables[$cid _tables[$j]] =$count;}foreach($cid 0_tables as $k=$v){ Echo("\ T".)$k." =".$v." \ n "); $sql= "UPDATE".$k." SET cid = ".$cid." WHERE cid = 0 "; $DBI->execute ($sql);}?>
Support MySQL database management with PHP script 5-Check Exception data