通行证: 用户 密码 域名空间  下载中心 社区论坛 信息公告 my小屋
联系我们
设为首页
加入收藏

 

qq,asp,php,jsp,xml,sql,.net,编程 程序 网页图象 建站经验 私服
首页 | 新闻资讯 | 编程开发 | 网页设计 | 图形图象 | 网络媒体 | 网站模板 | 数 据 库 | 投稿
论坛 | 操作系统 | 系统优化 | 网络安全 | 黑客技术 | 硬件学堂 | 硬件报价 | 服 务 器 | 地图
专题 | 应用软件 | 聊天通讯 | q q 专栏 | 建站经验 | 在线工具 | 站长club | 注 册 表 | 旧版
社会 | 游戏娱乐 | 设计欣赏 | 疑难解答 | 社区论坛 | 网络赚钱 | 网站地图 | 广告服务 | 服务
当前位置:首页>>编程开发>>sql专区>>正文 新版上线![旧版]
注:打开慢时请稍等
mysql用于php的库, 对数据库进行操作

http://www.iyit.net  日期:2006-5-3 19:19:32  来源:  点击:
参加讨论
<?
/*
* utility routines for mysql.
*/

class mysql_class {
var $db, $id, $result, $rows, $data, $a_rows;
var $user, $pass, $host;

/* make sure you change the username and password to your name and
* password for the db
*/

function setup ($user, $pass) {
$this->user = $user;
$this->pass = $pass;
}

function create ($db) {
if (!$this->user) {
$this->user = "username"; /* 在这里作修改 */
}
if (!$this->pass) {
$this->pass = "password"; /* 在这里作修改 */
}
$this->db = $db;
$this->id = @mysql_pconnect($this->host, $this->user, $this->pass) or
mysql_errormsg("unable to connect to mysql server: $this->host : '$server_name'");
$this->selectdb($db);
}

function selectdb ($db) {
@mysql_select_db($db, $this->id) or
mysql_errormsg ("unable to select database: $db");
}

# use this function is the query will return multiple rows. use the fetch
# routine to loop through those rows.
function query ($query) {
$this->result = @mysql_query($query, $this->id) or
mysql_errormsg ("unable to perform query: $query");
$this->rows = @mysql_num_rows($this->result);
$this->a_rows = @mysql_affected_rows($this->result);
}

# use this function if the query will only return a
# single data element.
function queryitem ($query) {
$this->result = @mysql_query($query, $this->id) or
mysql_errormsg ("unable to perform query: $query");
$this->rows = @mysql_num_rows($this->result);
$this->a_rows = @mysql_affected_rows($this->result);
$this->data = @mysql_fetch_array($this->result) or
mysql_errormsg ("unable to fetch data from query: $query");
return($this->data[0]);
}

# this function is useful if the query will only return a
# single row.
function queryrow ($query) {
$this->result = @mysql_query($query, $this->id) or
mysql_errormsg ("unable to perform query: $query");
$this->rows = @mysql_num_rows($this->result);
$this->a_rows = @mysql_affected_rows($this->result);
$this->data = @mysql_fetch_array($this->result) or
mysql_errormsg ("unable to fetch data from query: $query");
return($this->data);
}

function fetch ($row) {
@mysql_data_seek($this->result, $row) or
mysql_errormsg ("unable to seek data row: $row");
$this->data = @mysql_fetch_array($this->result) or
mysql_errormsg ("unable to fetch row: $row");
}

function insert ($query) {
$this->result = @mysql_query($query, $this->id) or
mysql_errormsg ("unable to perform insert: $query");
$this->a_rows = @mysql_affected_rows($this->result);
}

function update ($query) {
$this->result = @mysql_query($query, $this->id) or
mysql_errormsg ("unable to perform update: $query");
$this->a_rows = @mysql_affected_rows($this->result);
}

function delete ($query) {
$this->result = @mysql_query($query, $this->id) or
mysql_errormsg ("unable to perform delete: $query");
$this->a_rows = @mysql_affected_rows($this->result);
}
}

/* ********************************************************************
* mysql_errormsg
*
* print out an mysql error message
*
*/

function mysql_errormsg ($msg) {
# close out a bunch of html constructs which might prevent
# the html page from displaying the error text.
echo("</ul></dl></ol>n");
echo("</table></script>n");

# display the error message
$text = "<font color="#ff0000" size=+2><p>error: $msg :";
$text .= mysql_error();
$text .= "</font>n";
die($text);
}
?>


编辑:黑鹰 [发送给好友] [打印本页] [关闭窗口] [返回顶部]
上一篇:将oicq数据转成mysql数据
下一篇:php+mysql+javascript数据库查询结果的动态显示
转载请注明来源:www.iyit.net
特别声明: 本站除部分特别声明禁止转载的专稿外的其他文章可以自由转载,但请务必注明出处和原始作者。文章版权归文章原始作者所有。对于被本站转载文章的个人和网站,我们表示深深的谢意。如果本站转载的文章有版权问题请联系编辑人员,我们尽快予以更正。

 相关文章
第十七章 sql编程(二) 第十七章 sql编程(一) php 4.0 rc2 - win32安装指南(中文版)
apache, php在windows 9x/nt下的安装与 apache, php在windows 9x/nt下的安装与 windows2000下安装apache php4 mysql  
对《windows 9x/nt下以apache的模块方式 windows 2000下安装php4及mysql大揭密  win2000 + php + mysql + tomcat + jsp
超级服务器apache+mysql+php+ssl之完全 超级服务器apache+mysql+php+ssl之完全 如何在linux下装php+jsp的            
linux下快速安装“apache+php3+mysql” 如何集成linux、apache、php4、fastcgi 接触 solaris : 安装 apache + php + m
在linux下安装php,apache,oracle,perl的 unix下的php环境配置,+apache          linux服务器配置方案mysql(上)
sql server 7.0与以前的版本相比,安全 设置proxy server和sql server实现互联 microsoft sql server 7.0安全问题    
mysql安全性指南(3)(转)             mysql安全性指南 (2)(转)            mysql安全性指南 (1)(转)           
最新更新 热点排行 推荐新闻
sql server 7.0与以前的版本相比,安全
设置proxy server和sql server实现互联
microsoft sql server 7.0安全问题   
mysql安全性指南(3)(转)           
mysql安全性指南 (2)(转)          
在frontpage 2000中插入flash动画
用frontpage 2000使图像“减肥”
提高frontpage 2002使用效率
用frontpage 2000创建网页动画
用frontpage 2000巧做样式表
用frontpage 2000制作鼠标光照特效
用frontpage轻松转换图片格式
frontpage10全透视教程(9)
frontpage10全透视教程(8)
frontpage10全透视教程(7)
sql server 7.0与以前的版本相比,安全
sql简明教程(6)
sql简明教程(5)
sql简明教程(4)
sql简明教程(3)
qq珊瑚虫外挂4.0版本发布!
多个广告位招商!
摄影后期系列一:1分钟为数码相片去红眼
qq挂机说明
asp进度条
photoshop通道抠图:给秀发飞扬的mm照
教您显示器亮度对比度的调节
新版上线,今日正式开通!!!
更多精彩图文广告等着您!
asp中使用sql语句教程
sql简明教程(1)
第二十章 开发delphi对象式数据管理功
sql简明教程(1)
vbscript和javascript互相调用 
jsp教程(四)-jsp actions的使用
操作系统被入侵后的修复过程
五一别忘电脑防毒 养成良好上网习惯
google对ie浏览器将捆绑搜索功能表担忧
新版上线,今日正式开通!!!
用photoshop创意图形“岁月”
摄影后期系列一:1分钟为数码相片去红眼

 友情链接
设置首 页 - 版权声明 - 广告服务 - 关于我们 - 联系我们 - 友情连接
copyrights © 2004-2006 iyit.net all rights reserved.
网站合作、广告联系qq:147007642、466949678
易特网络技术 点击这里给我发消息