select"/> select">
Home > Article > Backend Development > PHP database call class call instance database settings php array insertion database php firebird database ph
<?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(); ?>
The above introduces the PHP database calling class calling examples, including database and PHP content. I hope it will be helpful to friends who are interested in PHP tutorials.