ITPUB??ì3
12月微软Hyper-V虚拟化沙龙主题征集
ITPUB论坛 » MySQL及其它开源数据库 » mysql与绑定变量

标题: mysql与绑定变量
离线 jianghc
一般会员



精华贴数 0
个人空间 0
技术积分 142 (12799)
社区积分 0 (93578)
注册日期 2003-8-13
论坛徽章:0
      
      

发表于 2004-8-11 17:38 
mysql与绑定变量

用惯了oracle等数据库,刚开始用mysql,有一个问题想向大家请教一下:
mysql里的sql,能使用绑定变量嘛?比如:
query1.sql.text := 'select * from user where user=:name';
query1.parambyname('name').asstring := 'root';
query1.open;
不知道以上代码需要怎样写在mysql里才能用?


__________________
Unix+Oracle8/Oracle9 9iOCP提供浙江地区Oracle现场技术支持服务,包括性能调整,数据库升级,移植及DataGuard,RAC等有合作意向联系OICQ:55101173
顶部
离线 ocptobe
资深会员



精华贴数 0
个人空间 0
技术积分 1790 (943)
社区积分 66 (4326)
注册日期 2002-3-4
论坛徽章:3
管理团队2006纪念徽章会员2006贡献徽章授权会员   
      

发表于 2004-8-12 09:32 
新版的PHP5提供的接口mysqli支持Bound Parameters,mysql版本需要4.1以上,例子:
PHP code:


<%php

$mysqli 
= new mysqli('localhost''user''password''world'); 

$stmt $mysqli->prepare(&quot;INSERT INTO CountryLanguage VALUES (?, ?, ?, ?)&quot<img src="images/smilies/23.gif" smilieid="206" border="0" alt="" />; 

$stmt->bind_param('sssd'$code$language$official$percent); 



$code 'DEU'

$language 'Bavarian'

$official = &quot;F&quot;; 

$percent 11.2



/* execute prepared statement */ 

$stmt->execute();

%>




__________________
To the world you may be one person,but to one person you may be the world.
顶部
 
    


CopyRight 1999-2006 itpub.net All Right Reserved.
北京皓辰广域网络信息技术有限公司. 版权所有
E-mail:Webmaster@itpub.net
京ICP证:010037号 联系我们 法律顾问