607的彩的正确网址

现在的位置: 607的彩的正确网址 > 数据库 > 正文

如何用php pdo连接数据库

2020年02月13日 数据库 ⁄ 共 1711字 ⁄ 字号 评论关闭

607的彩的正确网址  pdolianjieshujukudeyoudianshinengshixianbutongshujukuzhijiandezhuanhuan,erqieyoushiwugongnengdehuigun,gengyoupdo::prepare();pdo:::execute()hanshudeyuchulichaxun,suoyiwogerenrenweipdodegongnenghaishibijiaoqiangdade,suoyouzheipianrizhizhiweiwozijierxie,xiwangkandaozheipianrizhidexiongdimennengduinimenyousuobangzhu。

  yaoyongphplianjieshujukushouxianyaoyaoshilihuapdodelei,bingqieyaoyoushujuyuan,fuwuqizhanghao,fuwuqimima。

  数据源是数据库类型,服务器名称,数据库名称的一个集合。

  query("set names gbk");//shezhicongshujukulimianchuandiguolaideshujudebianmageshi

  ?>

  shiwujieshao:shiwujieshaowojiutongguowozijidelijielaijiangjieyibianba,jiushixianyaoguanbishujukudezidongtijiaogongneng(shenmeshizidongtijiaogongneng?jiushidangwomenxiewanyigesqlyujuhou,anhuichejianzhixingbuqi,eryaojingguoteshudedaimachulicainengtijiaoshangqu,houmianwohuijieshaode)

  ranhouxiechuniyaozhixingdesqlyujubingjiangfanhuidejieguofujilianggebutongdebianliang,zhihoutijiao,ruguozaizhixingdeshihouqizhong1gehuoduogefashenglecuowu,jiujinxingshiwuhuigun,jishihuiguichushizhuangtai(yejiushiqianmianzaishiwuchulidaimazhongdecharuhuogaibianhuoshanchuhuochaxundeyujuquanbuzuofei),haiyouyigeyoudianshibuhuiyinweijinruqitawangye,huozhixingqitasqlyujueryingxiangdaoshiwuchulidejincheng

607的彩的正确网址  //yixiashishiwuhuigundedaimajianjie

  query("set names gbk");//shezhicongshujukulimianchuandiguolaideshujudebianmageshi

607的彩的正确网址  $pdo->begintransaction();//zaizheiliguanbimysqldezidongtijiaogongneng

607的彩的正确网址  $a=$pdo->query("insert into tongxue values('130042106','tanyong','nan');

607的彩的正确网址  $b=$pdo->query("insert into tongxue values('130042100','zhubajie','nan')");

  if($a==true && $b==true){

607的彩的正确网址  $pdo->commit();//tijiaoshiwu

  } else{

  $pdo->rollback();//shiwuhuigun

  }

  ?>

  yongmysql_num_rows()hanshunengshuchushujukufanhuijieguojidexingshu,yicilaipanduangaiyonghushurudeyonghuminghemimashifouzhengque,neimezaipdozhongwomenruheshixianzheigegongnengni?

607的彩的正确网址  zaipdozhongyouyigehanshupdo::fetchall(),tadezuoyongshijiangcongshujukufanhuideyigejieguojiquanbufujihuoqutadezhi,zhihouzaiyongcount()hanshushuchuxingshujutishilidaimaruxia

607的彩的正确网址  query("set names gbk");//shezhicongshujukulimianchuandiguolaideshujudebianmageshi

607的彩的正确网址  $sql="select * from tongxue where id='130042106'";

  $shuju=pdo->prepare($sql);//zheijiushiwomensuoshuodeyuchuli

607的彩的正确网址  $shuju->execute();//zhixingyuchulidejieguo;

607的彩的正确网址  $jg=$shuju->fetchall(pdo::fetch_assoc);//jiangfanhuidejieguojiyishuzudefangshiquanbufanhuijibianliang$jg

607的彩的正确网址  $hangshu=count($jg);//shuchujieguojidexingshu

607的彩的正确网址  if($hangshu>0){

607的彩的正确网址  echo 'chaxunchulaishiyouzheigerende';

  } else{

  echo 'chaxunchulaishimeiyouzheigerende';

  }

  ?>

  dangwomendeyemianyunxingdesqlyujujiaoduoshi,keyiyongpdodangzhongdeyuchuli,laijianhuanfuwuqideyali,zheiduiyuneixieyaozuodaxingwangzhandexiangmulaishuoshiyigebucuodexuanze,yinweidaxingwangzhanyitiandeliulanliangshijiwanhuoshijiwande。

  下面我们来看看pdo的预处理

607的彩的正确网址  query("set names gbk");//shezhicongshujukulimianchuandiguolaideshujudebianmageshi

  $sql="insert into tongxue values('130042100','laoshi','nan')";//womenyaozhixingdesqlyuju

607的彩的正确网址  $shuju=$pdo->prepare($sql); //yuchuli

  $shuju->execute();//zhixingyuchulidesqlyuju

607的彩的正确网址  if($shuju){

  echo 'zhixingchenggong';

  } else{

607的彩的正确网址  echo 'zhixingshibai';

  }

  ?>

607的彩的正确网址  yishangjiushiyouguanphp pdolianjieshujukudexiangguanjieshao,yaolejiegengduojishuzhishi,qingshangxuebuyuan。

baoqian!pinglunyiguanbi.

2元中国福利彩票怎么看 2元买彩票选几个数字 2元中国福利彩票的买法 2元就可以打1毛的斗地主棋牌 2元彩是值得您信赖的 2元斗地主群 2元的彩的网 2元彩票双色球走势图双色球 2元彩票网全国走势图 2元就可以打1毛的炸金花棋牌