Support MySQL database management with PHP script 5-Check Exception data

Source: Internet
Author: User
Tags php script

<?PHP$DBI=NewDbmysql;$DBI-&GT;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&GT;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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.