Re: Database library recommended
| From: | Robert Williams | Date: | Wed, 18 Mar 2015 23:24:24 +0000 |
| Subject: | Re: Database library recommended | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-324663@lists.php.net to get a copy of this message | ||
> On Mar 18, 2015, at 08:27, R B <rbpphp@gmail.com> wrote:
>
> I want to know which is the database library currently recommended?
It depends on what you’re building and what database you’re using. If you’re talking about
MySQL, PHP offers two supported options: mysqli and PDO. The former is purpose-built for MySQL,
while the latter is a cross-database solution that makes it easy to port your code to other database
systems.
For anything that you expect to really scale up, or where high performance is critical, I strongly
suggest using Mysqli. The cross-database nature of PDO means that there’s an extra abstraction
layer between your application and the database, and that slows things down. In particular, you
can’t properly tune queries to the database, which is important because the database is the
slowest part of most applications. You also can’t properly utilize some advanced features that are
database-specific.
OTOH, if you’re developing a retail application that you expect customers to use with a variety of
DBMSes, PDO may be the best way to go, at least initially. Eventually, as you scale up, I still
suggest targeting specific databases that you want to support; if done right in terms of code
architecture, this need not impact your application code too much — mostly, making some
compromises on the data structures to work well with all of the databases rather than being highly
optimized for one.
Regardless, you don’t want to use the mysql API (note missing trailing ‘i’), as it was long
ago deprecated and is no longer supported.
--
Bob Williams
Business Unit Information Officer and
Senior Vice President of Software Development
Newtek Business Services Corp.
(602) 263-0300 x12458 | http://www.thesba.com/
Notice: This communication, including attachments, may contain information that is confidential. It
constitutes non-public information intended to be conveyed only to the designated recipient(s). If
the reader or recipient of this communication is not the intended recipient, an employee or agent of
the intended recipient who is responsible for delivering it to the intended recipient, or if you
believe that you have received this communication in error, please notify the sender immediately by
return e-mail and promptly delete this e-mail, including attachments without reading or saving them
in any manner. The unauthorized use, dissemination, distribution, or reproduction of this e-mail,
including attachments, is prohibited and may be unlawful. If you have received this email in error,
please notify us immediately by e-mail or telephone and delete the e-mail and the attachments (if
any).