PHP数据库调用类调用实例,php数据库调用实例
<?PHP require_once("mssql.class.php"); //1.创建类,并连接数据库 $db = new mssql("dns=aaa;uid=sa;pwd=sa;dbname=test"); //2.连接数据库 $conn = $db->config("dns=aaa;uid=sa;pwd=sa;dbname=test"); //3.选择数据库 $dbname = $db->select_db("test"); //4.设置允许调试 $db->debug = true; //5.执行一条不返回结果的SQL语句 $db->execute("insert into test01(name) values('这是一个测试!')"); //$db->exec(""); //6.执行一条返回结果的SQL语句 $rs = $db->query("select * from test01"); //7.以row方式显示结果 echo "<br>以row方式显示结果集<br>"; while($r = $db->fetch_row($rs)){ echo $r[0].":".$r[1]."<br>"; } //8.以array方式显示结果 $rs2 = $db->query("select * from test01"); echo "<br>以array方式显示结果集<br>"; while($r = $db->fetch_array($rs2)){ echo $r["id"] . ":" . $r["name"] . "<br>"; } //X.释放 $db->db_close(); ?>

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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

WebStorm Mac version
Useful JavaScript development tools

Zend Studio 13.0.1
Powerful PHP integrated development environment

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

Dreamweaver CS6
Visual web development tools