PHP数据库万能引擎类adodb配置使用以及实例集锦_PHP
ADODB PHP数据库万能引擎类特点:
1.可以在PHP规范各类数据库的链接和使用
2.可以帮助我们在PHP提供开发效率和快速转换各类数据库
3.使用相对简单
4.写作要求比较严谨,注意大小写
5.内置函数比较丰富
如何配置和使用ADODB PHP
1.下载ADODB For PHP 类库压缩包
2.解压到网站目录下任何文件夹下
3.引入ADODB配置文件
4.配置需要的数据库连接
5使用内置方法操作链接的数据库
连接MySql:
复制代码 代码如下:
include_once("adodb5/adodb.inc.php"); //包含adodb类库文件
$db = NewADOConnection('mysql');
$db->Connect('localhost', 'root', 'root', 'test')or die("df"); //连接MySQL数据库
?>
连接Access:
复制代码 代码如下:
include_once("adodb/adodb.inc.php"); //包含adodb类库文件
$conn = NewADOConnection('access'); //连接Access数据库
$conn->Connect("test.mb")or die("cuowu");
?>
连接DB2:
复制代码 代码如下:
include("adodb/adodb.inc.php"); //包含adodb类库文件
$conn=NewADOConnection('db2'); //连接DB2数据库
$conn->Connect("driver={IBM db2 odbc DRIVER};database=mydb;hostname=localhost;port=50000;
protocol=TCPIP;uid=root; pwd=pass");
?>
连接PostgreSQL:
复制代码 代码如下:
include("adodb/adodb.inc.php"); //包含adodb类库文件
$conn = NewADOConnection('postgres');
$conn->Connect('localhost', 'root', 'pass', 'mydb'); //连接PostgreSQL数据库
?>
ADODB PHP实现快速查询功能
复制代码 代码如下:
include_once("adodb5/adodb.inc.php");
$db = &NewADOConnection('mysql');
$db->Connect("localhost", "root", "", “db")or die("错误");
$db->Execute("set names 'GBK'");
$q=$db->Execute("select * from up_admin_user");
while($row=$q->FetchRow()){
print_r($row);
}
ADODB PHP实现智能插入功能
复制代码 代码如下:
include_once("adodb5/adodb.inc.php");
$db = &NewADOConnection('mysql');
$db->Connect("localhost", "root", "", “db")or die("错误");
$db->Execute("set names 'GBK'");
$arr=array('m_id'=>'2','password'=>'333333','33333'=>'4444444‘);
$db->AutoExecute("up_admin_user",$arr,"INSERT");
实例分享:
查询:
复制代码 代码如下:
include_once("adodb5/adodb.inc.php"); //包含adodb类库文件
$db = NewADOConnection('mysql');
$db->Connect('localhost', 'root', '', 'think_zw')or die("error"); //连接MySQL数据库
$db->Execute("set names 'GBK'");
$query=$db->Execute("select * from think_zw");
while($row=$query->FetchRow()){
print_r($row);
}
?>
插入:插入时它会自动过滤掉没有用的数组。排除掉没有用的数组。
字段都可以不对应的插入。
复制代码 代码如下:
include_once("adodb5/adodb.inc.php"); //包含adodb类库文件
$db = NewADOConnection('mysql');
$db->Connect('localhost', 'root', '', 'think_zw')or die("error"); //连接MySQL数据库
$db->Execute("set names 'GBK'");
$arr=array("id"=>"",
"name"=>"小军",
"details"=>"小军爱看美女");//注意不要把双引号写成单引号
$db->AutoExecute("think_zw",$arr,"INSERT");
$query=$db->Execute("select * from think_zw");
while($row=$query->FetchRow()){
echo $row[name]."
";
}
?>
===============================
PHP ADODB 地址方式连接数据库:
复制代码 代码如下:
include_once("adodb5/adodb.inc.php");
$db = NewADOConnection('mysql://root:@localhost/upload');
$sql="SELECT * FROM `pic`";
$db->SetFetchMode(ADODB_FETCH_ASSOC);//ADODB_FETCH_NUM这里和那个fetch_array和 fetch_row区别有点类似
//mysql_fetch_array()
$sr1 = $db->Execute($sql);
print_r($sr1->fields);
PHP ADODB 对象方式获取数据库内容
复制代码 代码如下:
$db = NewADOConnection('mysql');
$db->PConnect("localhost", "root", "", "upload");
$sql="SELECT * FROM `pic`";
$rs2=$db->Execute($sql);
while($row=$rs2->FetchNextObject()){
echo $row->NAME;
}
PHP ADODB HTML代码方式显示内容
复制代码 代码如下:
include_once("adodb5/tohtml.inc.php");
$db = NewADOConnection('mysql');
$db->Connect("localhost", "root", "", "upload");
$sql="SELECT * FROM `pic`";
$rs2=$db->Execute($sql);
echo rs2html($rs2);
PHP ADODB 实现内容自动分页功能
复制代码 代码如下:
include_once("adodb5/adodb-pager.inc.php");
session_start();
$db = NewADOConnection('mysql');
$db->Connect("localhost", "root", "", "upload");
$db->Execute("set names 'GBK'");
$sql="SELECT * FROM `pic`";
$pager=new ADODB_Pager($db,$sql);
$pager->Render(2);

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

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

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

Working with database in CakePHP is very easy. We will understand the CRUD (Create, Read, Update, Delete) operations in this chapter.

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

To work on file upload we are going to use the form helper. Here, is an example for file upload.

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Validator can be created by adding the following two lines in the controller.

Logging in CakePHP is a very easy task. You just have to use one function. You can log errors, exceptions, user activities, action taken by users, for any background process like cronjob. Logging data in CakePHP is easy. The log() function is provide

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c
