PHP脚本,用于创建MySQL表的备份副本
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP脚本,用于创建MySQL表的备份副本相关的知识,希望对你有一定的参考价值。
The script below connects to a mysql database server on "localhost" using the login name "test" and password "123456" and then connects to the database "test". It then copies the table structure and data from the table "products" to a new table "products_bak". If the target table already exists the function returns false.
<?php if(copy_table('products', 'products_bak')) { echo "success "; } else { echo "failure "; } function copy_table($from, $to) { if(table_exists($to)) { $success = false; } else { $success = true; } return $success; } function table_exists($tablename, $database = false) { if(!$database) { } SELECT COUNT(*) AS count FROM information_schema.tables WHERE table_schema = '$database' AND table_name = '$tablename' "); } ?>
以上是关于PHP脚本,用于创建MySQL表的备份副本的主要内容,如果未能解决你的问题,请参考以下文章