日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

2015-03-19 create php alternative for myslq_result in mysqli(PHP)--PDO Tutorial for Mysql Developers

發布時間:2025/3/8 数据库 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 2015-03-19 create php alternative for myslq_result in mysqli(PHP)--PDO Tutorial for Mysql Developers 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

來源:http://www.bestwebframeworks.com/tutorials/php/152/create-php-alternative-for-mysql_result-in-mysqli/


內容:

If you are migrating from PHP 5.5 to a newer version of PHP - you might be interested in a?MySQL to MySQLi/PDO migration guide?- and use the?function mysql_result()?you might get a notice (in case your error_reporting is set to show deprecated warnings) that this function is deprecate. Since there is no 1:1 alternative you can build your own alternative in MySQLi like shown below:

代碼:

1 2 3 4 5 6 7 ????function?mysqli_result($result,$row,$field?=0){ ????????????//adjust?the?result?pointer?to?that?specific?row ????????????$result->date_seek($row); ????????????//?Fetch?rsult?array ????????????$data?=?$result->fetch_array(); ????????????return?$data[$field]; ????}

-----

PDO Tutorial for Mysql Developers

來源:http://wiki.hashphp.org/PDO_Tutorial_for_MySQL_Developers

why user pdo?

??? mysql_* functions are getting old. For a long time now mysql_* has been at odds with other common SQL database programing interface. It doesn't support modern SQL database concepts such as prepared statements,stored procs,transactions etc...

connectiong to mysql?

old way:?

??? <?php?

????????$link = mysql_connect('localhost','user','pass');

????????mysql_select_db('testdb',$link);

????????mysql_set_charset('UTF-8',$link);

new way :all you gotta do is create a new PDO object.

??????????? PDO's constructor takes at most 4 parameters--DSN,username,password, and an array of driver options.

????????????A DSN is basically a string of options that tell PDO which driver to use,and the connection details...

????????<?php

????????????$db = new PDO('mysql:host=localhost;dbname=testdb;charset=utf8','username','password');

NOTE:

????If you get an error about character sets, make sure you add the chaset parameter to the DSN. Adding the charset to the DSN is very important for security reasons,most examples you'll see around leave it out.?

????MAKE SURE TO INCLUDE THE CHARSET

????You can also pass in several driver options as an array to the fourth parameters.

????

1 2 <?php ????$db?=?new?PDO('mysql:host=localhost;dbname=testdb;charset=utf8',?'username',?'password',?array(PDO::ATTR_EMULATE_PREPARES?=>?false,?????????????????????????????????????????????????????????????????????????????????????????????PDO::ATTR_ERRMODE?=>?PDO::ERRMODE_EXCEPTION));

you can also set some attributes after PDO construction with the setAttribute method:

<?php $db?=?new?PDO('mysql:host=localhost;dbname=testdb;charset=utf8',?'username',?'password'); $db->setAttribute(PDO::ATTR_ERRMODE,?PDO::ERRMODE_EXCEPTION); $db->setAttribute(PDO::ATTR_EMULATE_PREPARES,?false

Error Handling

????Consider your typical mysql_error handling?

1 2 3 ????<?php ????//connected?to?mysql? ????$result?=?mysql_query("select?*?from?table",$link)?or?die(mysql_error($link));

?? OR die is a? pretty bad way to handle errors, yet this is typical mysql code.You can't handle die(); as it will just end the scipt abruptly and then echo the error to the screen which you usually do NOT want to show to your end users allowing nasty hackers discover your schema.

????PDO has three error handling modes.

本文轉自孤舟夜航之家博客51CTO博客,原文鏈接http://blog.51cto.com/cysky/1622129如需轉載請自行聯系原作者


cysky

總結

以上是生活随笔為你收集整理的2015-03-19 create php alternative for myslq_result in mysqli(PHP)--PDO Tutorial for Mysql Developers的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 男女黄色录像 | 亚洲综合欧美 | 国产69精品久久久久999小说 | 神马午夜av| 古装做爰无遮挡三级视频 | a天堂在线观看 | 国产日视频 | 凹凸精品熟女在线观看 | 成人一区二区精品 | 久久久久亚洲AV成人无码国产 | 精品国产乱码久久久久久闺蜜 | 性欧美极品另类 | 亚洲午夜av | 操一操视频| 国产又大又黄又爽 | 亚洲视频大全 | 亚洲精品伊人 | 男男大尺度| 日本国产视频 | 国产色无码精品视频 | 黄色av网站网址 | 麻豆影视国产在线观看 | 午夜精品国产 | 亚洲天堂手机在线观看 | 欧美日韩高清不卡 | v8888av| 日韩三级麻豆 | 国产激情综合五月久久 | 日韩av.com| www久久99| 寡妇一级片| 久久永久免费 | 五月天婷婷色综合 | 成人短视频在线观看 | 老司机精品在线 | 日本a级黄| 亚洲精品综合网 | 国产免费观看av | 欧美精品在线观看 | 黄瓜视频在线播放 | a级片在线观看视频 | 日本乱淫视频 | 夜久久 | 嫩草国产在线 | 日本国产亚洲 | 黄色的网站免费看 | 在线成人日韩 | 高清一区二区三区四区五区 | 青青草久久爱 | 亚洲成人播放 | 天天躁日日躁狠狠躁av麻豆 | 人操人| 国产一区二区三区亚洲 | 成人特级毛片69免费观看 | 91色网站 | 成年人毛片 | 亚洲s码欧洲m码国产av | 丰满少妇被猛烈进入高清播放 | 午夜性色福利视频 | 艹久久| 欧美日韩一区二区三区电影 | 亚洲成年人免费观看 | 一区二区xxx| 成人涩涩网| 中国美女一级黄色片 | 日日爽夜夜爽 | 欧美日韩国产在线播放 | 中文字幕在线资源 | 色情毛片| 三级精品在线 | 一本色综合 | 欧美精品99久久 | 狠狠干很很操 | 国产精品一区二区三区久久久 | 超级乱淫视频 | 日本一区二区三区在线播放 | 超能一家人电影免费喜剧在线观看 | exo妈妈mv在线播放高清免费 | 射进来av影视网 | 亚洲性少妇 | 久久综合激情 | 小泽玛利亚在线 | 麻豆影视在线免费观看 | 色涩av| 精品国产乱码久久久久久闺蜜 | 美女脱了内裤喂我喝尿视频 | www99re| 久久久精品久久久久久 | 欧美性生交xxxxx | 免费黄色在线 | 亚洲黄色大片 | 亚洲国产欧美在线人成 | 亚洲老女人 | 伊人久久五月 | 顶臀精品视频www | 久久av一区二区三区 | 国产高清av在线 | 77久久| 日韩视频在线观看二区 |