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

WBOY
Release: 2016-07-13 10:25:56
Original
749 people have browsed it

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...
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template