php开源嘛
首页 | English | MySql数据库 | Php编程 | 建站杂烩 | 系统服务器 | 资源共享 | 专题 | 才桀网 | 支持论坛
  当前位置:主页>Php编程>文章内容
mysql的新特性的一个扩展mysqli的介绍...
来源:phpe 作者:本站整理 发布时间:2008-01-16  

1.和以前mysql.dll一样的方法:

<?php 

/* Connect to a MySQL server */ 
$link = mysqli_connect( 
           'localhost',  /* The host to connect to */ 
           'user',       /* The user to connect as */ 
           'password',   /* The password to use */ 
           'world');     /* The default table to query */ 

if (!$link) { 
  printf("Can't connect to MySQL Server. Errorcode: %s\n", mysqli_connect_error()); 
  exit; 
} 

/* Send a query to the server */ 
if ($result = mysqli_query($link, 'SELECT Name, Population FROM City ORDER BY Population DESC LIMIT 5')) { 

   print("Very large cities are:\n"); 

   /* Fetch the results of the query */ 
   while( $row = mysqli_fetch_assoc($result) ){ 
       printf("%s (%s)\n", $row['Name'], $row['Population']); 
   } 

   /* Destroy the result set and free the memory used for it */ 
   mysqli_free_result($result); 
} 

/* Close the connection */ 
mysqli_close($link); 
?> 



输出结果:

Very large cities are:

Mumbai (Bombay) (10500000)
Seoul (9981619)
S&atilde;o Paulo (9968485)
Shanghai (9696300)
Jakarta (9604900)




2.使用内置OO接口方式调用:

<?php 

/* Connect to a MySQL server */ 
$mysqli = new mysqli('localhost', 'user', 'password', 'world'); 

if (mysqli_connect_errno()) { 
  printf("Can't connect to MySQL Server. Errorcode: %s\n", mysqli_connect_error()); 
  exit; 
} 

/* Send a query to the server */ 
if ($result = $mysqli->query('SELECT Name, Population FROM City ORDER BY Population DESC LIMIT 5')) { 

   print("Very large cities are:\n"); 

   /* Fetch the results of the query */ 
   while( $row = $result->fetch_assoc() ){ 
       printf("%s (%s)\n", $row['Name'], $row['Population']); 
   } 

   /* Destroy the result set and free the memory used for it */ 
   $result->close(); 
} 

/* Close the connection */ 
$mysqli->close(); 
?> phpma开源

支持的新特性还有:Bound Parameters,Bound Results等。。。
有兴趣的可以直接去参看原英文:
http://www.zend.com/php5/articles/php5-mysqli.php#fn3

注:感觉这个不是对所有人都有用。不过。。。相信可以帮助大家多了解些“变化”,能更好的把握“趋势” 8-)

(阅读次数:
共2页: 上一页 [1] 2 下一页
上一篇:Ajax技术(五)用AjaxTags简化Ajax开发   下一篇:Linux 系统下 ssh 安全设置指南
[收藏] [推荐] [评论(0条)] [返回顶部] [打印本页] [关闭窗口]  
用户名: 新注册) 密码: 匿名评论
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
 §最新评论
  热点文章
·PHP生成验证码图片的源代码
·PHP会话对(Session)使用入门
·Php部分常见问题总结[bug]
·php正则表达式的快速学习方法
·高手传经:学习PHP重在坚持
·用php生成静态页面的php函数
·PHP对文本数据库的基本操作方法
·用 PHP 读取文件的正确方法
·讲解PHP+MySQL的分页显示示例
·用PHP构建一个简易监视引擎
·我是怎样打造简单的PHP&MYSQL留
·用PHP实现表单验证码登陆校验
  相关文章
·php实现英文星期几转为中文的两
·PHP中使用Sockets 从Usenet中获
·PHP杂烩:一个基于PHP的事件机制
·黑客隐藏PHP文件后门的技巧...
·实例学习动态网页PHP的语法{初学
·PHP编程:使用PHP生成1000个随机
·PHP与js(Javascript)的两种交互
·PHP5的DirectoryIterators递归扫
·增加PHP的Session存储和处理能力
·Web2.0时代PHP将受更多人的青睐
·php的xml分析函数、精彩阅读...
·PHP中的面向对象和面向过程OOP…

关于我们 | 本站声明 | 友情连接 | 诚邀加盟 | 网站地图
版权Power by DedeCms   技术支持QQ =>> 罗江游鱼   Jacking  后台登陆
Copyright @ 2007 公司地址:柳州市东环路268号 邮编:545006 电话:15920389818 桂ICP备07006725号