Home >Backend Development >PHP Tutorial >How to implement batch change of database table prefix in PHP_PHP Tutorial

How to implement batch change of database table prefix in PHP_PHP Tutorial

WBOY
WBOYOriginal
2016-07-13 10:25:56782browse

Using the following method, it can be easily done. The code is as follows, if you find it useful, please give me some advice.

Copy code The code is as follows:

                                                                                                           
$user = "root"; //Database user name
$pwd = "pwd"; //Database password
$replace ='pre_';                                                                                                                         // Replaced prefix
                                         = 'pre1_';                                                                                                                                                                                                                                   . Connect to database

$tables = mysql_list_tables("$database");

while($name = mysql_fetch_array($tables)) {

                $table = str_replace($seach,$replace,$name['0']); 🎜>

?>


If you want to add a prefix, you only need to change it a little bit


Copy the code

The code is as follows:
$table = str_replace($seach,$replace,$name['0']); Replace with $table = $replace.$name['0'];
That’s it.



http://www.bkjia.com/PHPjc/824860.htmlwww.bkjia.com

truehttp: //www.bkjia.com/PHPjc/824860.htmlTechArticleUsing the following method, you can easily do it. The code is as follows, if you find it useful, please give it a thumbs up. Copy the code The code is as follows: ?php $database = "databaseName"; //Database name $user = "root"; //Database...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn