MySQL数据库函数
来源:互联网 发布:ubuntu挂载u盘 编辑:程序博客网 时间:2024/06/06 02:05
<iframe style="WIDTH: 89.81%; HEIGHT: 64px" src="http://pagead2.googlesyndication.com/pagead/ads?client=ca-pub-4577827332549849&dt=1192819750500&lmt=1192819750&prev_fmts=468x60_as&format=468x15_0ads_al_s&output=html&correlator=1192819750437&channel=1741427766&pv_ch=1741427766%2B&url=http%3A%2F%2Fyzkzoo.5d6d.com%2Fthread-68-1-1.html&color_bg=FFFFFF&color_text=000000&color_link=0000FF&color_url=008000&color_border=336699&ref=http%3A%2F%2Fyzkzoo.5d6d.com%2Fforum-16-1.html&cc=100&ga_vid=1025434795.1192631677&ga_sid=1192817968&ga_hid=1871659779&ga_fc=true&flash=8&u_h=768&u_w=1024&u_ah=738&u_aw=1024&u_cd=32&u_tz=480&u_his=2&u_java=true"></iframe>
<iframe style="WIDTH: 82.23%; HEIGHT: 74px" src="http://pagead2.googlesyndication.com/pagead/ads?client=ca-pub-4577827332549849&dt=1192818497343&lmt=1192818497&format=468x60_as&output=html&correlator=1192818497343&channel=1741427766&url=http%3A%2F%2Fyzkzoo.5d6d.com%2Fthread-68-1-1.html&color_bg=FFFFFF&color_text=000000&color_link=0000FF&color_url=008000&color_border=336699&ad_type=text_image&ref=http%3A%2F%2Fyzkzoo.5d6d.com%2Fforumdisplay.php%3Ffid%3D16%26page%3D1&ui=rc%3A6&cc=100&ga_vid=1025434795.1192631677&ga_sid=1192817968&ga_hid=1000484876&ga_fc=true&flash=8&u_h=768&u_w=1024&u_ah=738&u_aw=1024&u_cd=32&u_tz=480&u_his=6&u_java=true"></iframe>
(1) int mysql_affected_rows([int link_id]);
在给定的连接中,返回由最近的DELETE、INSERT、REPLACE或者UPDATE语句所作用的行数。如果没有行
被修改,则mysql_affected_rows()返回0,如果出现错误,则返回-1。
在SELECT查询之后,mysql_affected_rows()返回所选择的行数。但一般是与SELECT语句一道使用
mysql_num_rows().
使用范例:
<?php
$link=mysql_pconnect("localhost","sunsoft","suixiang") or die("Could not connect");
mysql_select_db("samp_db") or die("Could not select database");
$query="INSERT INTO
member(last_name,first_name,expiration)"."VALUES('Brown','Marcia','2002-6-3')";
$result=mysql_query($query) or die("Query failed");
printf("%d row%s insertedn",mysql_affected_rows(),mysql_affected_rows()==1?" ":"s");
?>
(2) int mysql_close(int[link_id]);
关闭由link_id标识的与MySQL服务器的连接。如果没有指定连接,则mysql_close()关闭最近打开的连
接。如果成功,则mysql_close()返回真,失败则返回假。对由mysql_pconnect()打开的永久连接,
mysql_close()忽略相应的关闭请求,只是返回值。如果要关闭一个连接,就应该用mysql_connect()而不是
mysql_pconnect()来打开它。
使用范例:
<?php
$link=mysql_connect("localhost","sunsoft","suixiang") or die("Could not connect");
print("Connected successfully");
mysql_close($link);
?>
(3) int mysql_connect(string [hostname] [:port], string [username], string [password]);
本函式建立与 MySQL 伺服器的连线。其中所有的参数都可省略。当使用本函式却不加任何参数时,参
数 hostname 的内定值为 localhost、参数 username 的内定值为 PHP 执行行程的拥有者、参数 password 则
为空字串 (即没有密码)。而参数 hostname 后面可以加冒号与埠号,代表使用那个埠与 MySQL 连接。当然在
使用资料库时,早点使用 mysql_close() 将连线关掉可以节省资源。
使用范例
这是一位未具名网友提供的范例 (18-Feb-1999)
<?php
$dbh = mysql_connect('localhost:3306','mcclain','standard');
mysql_select_db('admreqs');
$query = "insert into requests(date, request, email, priority,status) values
(NOW(),'$description', '$email', '$priority', 'NEW')";
$res = mysql_query($query, $dbh);
$query = "select max(id) from requests";
$res = mysql_query($query, $dbh);
$err = mysql_error();
if($err){
echo "发生错误,请通知<a href=mailto:webmaster@my.site>站长</a>";
}
$row = mysql_fetch_row($res);
echo "未来您使用的号码为: ".$row[0];
?>
(4) int mysql_create_db(string db_name [, int link_id]);
告诉由link_id标识的MySQL服务器用给定的名称来创建数据库。如果数据库创建成功,则返回真;如
果出现错误,则返回假。必须在数据库有创建它的CREATE权限。
可能利用mysql_query()较利用mysql_create_db()发布CREATE DATABASE 语句更为适合。
<?php
$link=mysql_pconnect("localhost","sunsoft","suixiang"); or die("Could not connect");
if(mysql_create_db("my_db"))
print("Database created successfullyn");
else
print("Error creating database:%sn",mysql_error());
?>
<iframe style="WIDTH: 44.33%; HEIGHT: 259px" src="http://pagead2.googlesyndication.com/cpa/ads?client=ca-pub-4577827332549849&cpa_choice=CAEaCB94-nvUZWENUB9QugJQtwRQTVAgULcCUB4&oe=gb2312&dt=1192720966468&lmt=1192720966&format=250x250_as&output=html&correlator=1192720966453&channel=2735220158&url=http%3A%2F%2Fyzkzoo.5d6d.com%2Fthread-67-1-1.html&color_bg=FFFFFF&color_text=000000&color_link=0000FF&color_url=008000&color_border=336699&ad_type=text_image&region=_google_cpa_region_&ref=http%3A%2F%2Fyzkzoo.5d6d.com%2Fforum-16-1.html&cc=100&ga_vid=1025434795.1192631677&ga_sid=1192720940&ga_hid=1155529757&ga_fc=true&flash=8&u_h=768&u_w=1024&u_ah=738&u_aw=1024&u_cd=32&u_tz=480&u_his=2&u_java=true"></iframe><iframe style="WIDTH: 52.39%; HEIGHT: 263px" src="http://pagead2.googlesyndication.com/cpa/ads?client=ca-pub-4577827332549849&cpa_choice=CAEaCKcC4yuPlq5lUDRQDVAtUK4BUENQCA&oe=gb2312&dt=1192819388296&lmt=1192819388&format=300x250_as&output=html&correlator=1192819388281&channel=2735220158&url=http%3A%2F%2Fyzkzoo.5d6d.com%2Fviewthread.php%3Ftid%3D70%26page%3D1%26extra%3Dpage%253D1&color_bg=FFFFFF&color_text=000000&color_link=0000FF&color_url=008000&color_border=336699&ad_type=text_image&region=_google_cpa_region_&ref=http%3A%2F%2Fyzkzoo.5d6d.com%2Fpost.php%3Faction%3Dedit%26fid%3D16%26tid%3D70%26pid%3D70%26page%3D1%26extra%3Dpage%253D1&cc=100&ga_vid=1025434795.1192631677&ga_sid=1192817968&ga_hid=1527165455&ga_fc=true&flash=8&u_h=768&u_w=1024&u_ah=738&u_aw=1024&u_cd=32&u_tz=480&u_his=5&u_java=true"></iframe>
<iframe style="WIDTH: 82.23%; HEIGHT: 74px" src="http://pagead2.googlesyndication.com/pagead/ads?client=ca-pub-4577827332549849&dt=1192818497343&lmt=1192818497&format=468x60_as&output=html&correlator=1192818497343&channel=1741427766&url=http%3A%2F%2Fyzkzoo.5d6d.com%2Fthread-68-1-1.html&color_bg=FFFFFF&color_text=000000&color_link=0000FF&color_url=008000&color_border=336699&ad_type=text_image&ref=http%3A%2F%2Fyzkzoo.5d6d.com%2Fforumdisplay.php%3Ffid%3D16%26page%3D1&ui=rc%3A6&cc=100&ga_vid=1025434795.1192631677&ga_sid=1192817968&ga_hid=1000484876&ga_fc=true&flash=8&u_h=768&u_w=1024&u_ah=738&u_aw=1024&u_cd=32&u_tz=480&u_his=6&u_java=true"></iframe>
<iframe style="WIDTH: 58.41%; HEIGHT: 156px" src="http://pagead2.googlesyndication.com/pagead/ads?client=ca-pub-4577827332549849&dt=1192819750656&lmt=1192819750&prev_fmts=468x60_as%2C468x15_0ads_al_s%2C234x60_as&format=200x90_0ads_al_s&output=html&correlator=1192819750437&channel=1741427766&pv_ch=1741427766%2B&url=http%3A%2F%2Fyzkzoo.5d6d.com%2Fthread-68-1-1.html&color_bg=FFFFFF&color_text=000000&color_link=0000FF&color_url=008000&color_border=336699&ref=http%3A%2F%2Fyzkzoo.5d6d.com%2Fforum-16-1.html&cc=100&ga_vid=1025434795.1192631677&ga_sid=1192817968&ga_hid=1871659779&ga_fc=true&flash=8&u_h=768&u_w=1024&u_ah=738&u_aw=1024&u_cd=32&u_tz=480&u_his=2&u_java=true"></iframe>
- MySQL数据库函数详解
- MySQL数据库函数
- MySQL数据库函数详解
- mysql数据库函数
- MySql数据库函数集
- mysql数据库函数
- Mysql数据库函数
- MySQL数据库函数
- Mysql数据库常用函数
- MySql数据库--mysql_real_escape_string()函数
- MySQL 数据库 password函数
- MySQL数据库内置函数
- Mysql 数据库中的函数
- mysql数据库-常用函数
- mysql 数据库函数
- MySQL数据库的函数
- MySQL数据库函数
- MySQL数据库函数(二)
- 一位浙大教授令人寒心的演讲---但我很欣赏
- C++复习 02 变量和基本类型
- MySQL的管理工具:phpMyAdmin
- CheckStyle 及其配置的详细解释
- Java 学习之了解 Java 的运行环境
- MySQL数据库函数
- 有关语言初学者用什么开发工具的理解
- 使用ORM工具进行数据访问
- phpMyAdmin 安装配置
- 简单的网页关键词匹配工具
- 使用JWhich工具管理CLASSPATH
- 组建网络时 路由器能替代防火墙吗?
- JBuilder2005单元测试之业务类介绍
- hbm2java和hbm2ddl工具的使用