問(wèn)題描述
重復(fù):mysqli 或 PDO - 有什么優(yōu)點(diǎn)和缺點(diǎn)?
我希望將網(wǎng)站從 mysql 轉(zhuǎn)移到 mysqli 或 pdo,主要作為學(xué)習(xí)工具,但如果可能的話,也會(huì)提高性能.
我已閱讀http://php.net/manual/en/mysqli.overview.php 似乎兩者都適合我的需求,但無(wú)論哪種方式都不強(qiáng)烈.
該站點(diǎn)目前主要使用非面向?qū)ο蟮拇a,但我確實(shí)有使用其他語(yǔ)言的 OO 的經(jīng)驗(yàn).絕大多數(shù)查詢都是簡(jiǎn)單復(fù)雜的選擇語(yǔ)句,很少有更新/插入.從我自己的教育和這個(gè)特定的網(wǎng)站來(lái)看,你認(rèn)為最有用的是什么?
如果您需要任何其他信息,請(qǐng)告訴我.
謝謝.
PDO Pro's:
- 自 5.x 起原生于 PHP
- 支持命名參數(shù)而不是以數(shù)字索引?的
- 同一個(gè)抽象庫(kù)支持多個(gè)不同的 RDBM
Mysqli Con 的:
- 在正確存儲(chǔ)和檢索大對(duì)象數(shù)據(jù)庫(kù).
- 不支持命名參數(shù).
否則,兩個(gè)庫(kù)基本上是同一事物的不同風(fēng)味.它們都有引用參數(shù)的函數(shù),并且都支持參數(shù)化查詢.
如果以上論點(diǎn)都沒(méi)有影響您,那么請(qǐng)根據(jù)語(yǔ)法、風(fēng)格等選擇您喜歡的庫(kù).
Duplicate: mysqli or PDO - what are the pros and cons?
I'm looking to move a website from mysql to either mysqli or pdo as primarily a learning tool, but also for performance increases if possible.
I have read through http://php.net/manual/en/mysqli.overview.php and it seems like both would suit my needs, but it doesn't lean strongly either way.
The site currently uses primarily non object orientated code, but I do have experience with OO in other languages. A huge majority of the queries are simple complex select statements with very little update/inserts. What do you suggest as being the most useful both from my own education and for this specific site?
If you need any additional information please let me know.
Thanks.
PDO Pro's:
- Native to PHP as of 5.x
- Supports named parameters as opposed to numerically indexed ?'s
- Same abstraction library supports multiple different RDBM's
Mysqli Con's:
- Has issues with properly storing and retrieving large objects in the database.
- No support for named parameters.
Otherwise, both libraries are basically different flavors of the same thing. They both have functions to quote parameters and both support parameterized queries.
If none of the above arguments sway you, then go with whichever library you prefer based on its syntax, style, etc.
這篇關(guān)于從 mysql 遷移到 mysqli 或 pdo?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!