問題描述
不久前有人建議我更改我的代碼以使用 PDO,以便參數化我的查詢并安全地將 HTML 保存在數據庫中.
I was suggested, not long ago, to change my code to use PDO in order to parameterize my queries and safely save HTML in the database.
嗯,這里是主要問題:
我看了http://php.net/manual/en/ref.pdo-mysql.php,我真的不知道我應該把那個
$ ./configure --with-pdo-mysql
字符串放在哪里...
I looked at http://php.net/manual/en/ref.pdo-mysql.php, and I don't really get where I should put that
$ ./configure --with-pdo-mysql
string...
我正在構建的網站實際上只需要一頁的 PDO.雖然我可能會考慮重新編寫它,但這需要一段時間,而且我需要盡快運行頁面,所以我不能完全關閉 MySQL.如果我安裝了 PDO,我還能使用 mysql_*
處理程序嗎?
The site I'm building actually only requires PDO for one page. While I may consider re-writing it, it would take a while and I need the pages to be running soon, so I can't turn off MySQL completely. If I do install PDO, will I still be able to use mysql_*
handlers?
有問題的服務器正在運行 PHP 版本 5.4.6-1ubuntu1 和 Apache/2.2.22 (Ubuntu).如果重要的話,我也在運行一個 phpMyAdmin 數據庫.
The server in question is running PHP Version 5.4.6-1ubuntu1 and Apache/2.2.22 (Ubuntu). I'm also running a phpMyAdmin database, if it matters.
推薦答案
在 Ubuntu 上,您應該能夠使用 sudo apt-get install php5-mysql
On Ubuntu you should be able to install the necessary PDO parts from apt using sudo apt-get install php5-mysql
同時使用 PDO 和 mysql_ 沒有限制.但是,您需要創建兩個到數據庫的連接,一個使用 mysql_,一個使用 PDO.
There is no limitation between using PDO and mysql_ simultaneously. You will however need to create two connections to your DB, one with mysql_ and one using PDO.
這篇關于在 MySQL Linux 服務器上安裝 PDO 驅動程序的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!