Re: any reason *not* to use PEAR DB module when accessing mysql?
| From: | larry@garfieldtech.com | Date: | Fri, 19 Mar 2010 16:18:31 +0000 |
| Subject: | Re: any reason *not* to use PEAR DB module when accessing mysql? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-303015@lists.php.net to get a copy of this message | ||
Add me to the list of people recommending PDO. It's much nicer to work with than the ext/mysql API, and frankly more secure since you get prepared statements. It won't get you complete database independence for a number of reasons (mostly due to databases being too unstandardized because they all suck in different ways; I say this as someone who has written an abstraction layer atop PDO and it wasn't easy), but it will get you part way there and even if you only ever use MySQL is a nicer API to work with.
--Larry Garfield
On 3/19/10 9:17 AM, Robert P. J. Day wrote:
(just a warning -- as a relative newbie to PHP, i'll probably have the occasional dumb question. just humour me.) i'm looking at some existing PHP code that accesses a mysql 5.0 db, and it's coded using the mysql-specific calls: mysql_connect, mysql_select_db, etc, etc. is there any reason i *wouldn't* want to rewrite that code using the more general PEAR DB module, and use mysqli? certainly, as i read it, using the PEAR DB module would make it easier down the road if i suddenly decide to change the DB backend. anyway, any compelling arguments for or against? rday -- ========================================================================Robert P. J. Day Waterloo, Ontario, CANADALinux Consulting, Training and Kernel Pedantry.Web page: http://crashcourse.ca Twitter: http://twitter.com/rpjday========================================================================