ADODB操作数据库函数Execute

来源:互联网 发布:python清屏 编辑:程序博客网 时间:2024/06/06 16:57

一 代码

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>应用结合变量执行查询操作</title><style type="text/css"><!--body,td,th {font-size: 12px;}body {margin-left: 10px;margin-top: 10px;margin-right: 10px;margin-bottom: 10px;}--></style></head><body><?phpinclude_once ('../adodb5/adodb.inc.php');//载入(include)adodb.inc.php文件$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;//设置字段为结果集索引$conn = ADONewConnection('mysql');//建立连接$conn -> PConnect('localhost','root','root','db_database14');//连接数据库$conn -> execute('set names gb2312');//设置编码格式$sqlstr = 'select * from tb_object where id = ?';//创建sql语句$rst = $conn -> execute($sqlstr,'1') or die('connect error');//执行sql语句,查询出id等于1的数据while(!$rst -> EOF){//如果没有错误,则配合wihle语句循环输出结果echo $rst -> fields['bigclass'].'=>'.$rst -> fields['d_time'].' ';//输出查询结果$rst -> movenext();//指针下移}$rst -> close();//关闭连接$conn -> close();?></body></html>

 

二运行结果
图书=>2008-02-27 16:46:48
原创粉丝点击