php+mysqli实现批量替换数据库表前缀的方法,mysqli前缀
本文实例讲述了php+mysqli实现批量替换数据库表前缀的方法。分享给大家供大家参考。具体分析如下:
在php中有时我们要替换数据库中表前缀但是又不苦于一个个表去修改前缀,这里我自己写了一个mysqli批量替换数据库表前缀的php程序,感兴趣的朋友可以参考一下,代码如下:
复制代码 代码如下:
header ( 'http-equiv="Content-Type" content="text/html; charset=utf-8"' );
$DB_host = "localhost"; //数据库主机
$DB_user = "root"; //数据库用户
$DB_psw = "root3306"; //数据库密码
$DB_datebase = "gk_yue39_com"; //数据库名
$DB_charset = "utf8"; //数据库字符集
$dbprefix="yue392_com_";
$new_dbprefix="yue39_com_";
$db = new mysqli ( $DB_host, $DB_user, $DB_psw ); //实例化对象
//检查连接
if (mysqli_connect_errno ()) {
printf ( "Connect failed: %sn", mysqli_connect_error () );
exit ();
}
$db->select_db ( $DB_datebase ); //选择操作数据库
$db->set_charset ( $DB_charset ); //设置数据库字符集
//执行一个查询
$sql = 'show tables';
$result = $db->query ( $sql );
echo $result->num_rows . ' 行结果 ' . $result->field_count . ' 列内容
';
//$result->data_seek('5');//从结果集中第5条开始取结果
echo '
' . $result->current_field . '_' . $field->name . '(' . $field->length . ') | ';|||
---|---|---|---|
' . $sql. ' | success | ';' . $sql. ' | failed | ';
$result->free ();//释放结果集
$db->close (); //关闭连接
?>
希望本文所述对大家的php程序设计有所帮助。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Atom editor mac version download
The most popular open source editor

SublimeText3 English version
Recommended: Win version, supports code prompts!

Notepad++7.3.1
Easy-to-use and free code editor
