Home > php教程 > PHP源码 > body text

ADODB的使用

PHP中文网
Release: 2016-05-25 17:11:39
Original
1439 people have browsed it

[PHP]代码   

Adodb的使用文档
1.       在adodb官网http://www.php.cn/下载adodb,在php脚本中引入核心文件adodb.inc.php例如:include(‘adodb/adodb.inc.php’)

2.       连接数据库类conn.php
<?php
include(&#39;adodb/adodb.inc.php&#39;);//包含ADODB的类库
$con=ADONewConnection(&#39;mysql&#39;);//MySql数据库
$db_host="localhost";//主机
$db_user="root";//用户名
$db_pass="";//密码
$db_name="forum";//数据库名
@$testConn=$conn->Connect($db_host,$db_user,$db_pass,$db_name);//连接数据库
if(!$testConn){
 echo "数据库连接失败!";
}
$ADODB_CACHE_DIR=&#39;tmp&#39;;
$conn->Execute("set names gb2312");//软件字符编码格式
?>



3.在其他页面调用该连接数据库类

require("configs/conn.php");//引入连接数据库类

$sql="select id,title,posttime,user from topic order by id desc";

$result=$conn->Execute($sql);//执行SQL语句

$articleAll=$result->GetArray();//获得数据表中所有的帖子

4.其他函数参考adodb文档
Copy after login

                   

                   

Related labels:
php
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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template