Re: Database library recommended

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 18 March 2015 23:24:24 GMT+00:00, Robert Williams <rewilliams@xxxxxxxxxx> wrote:
>
>> On Mar 18, 2015, at 08:27, R B <rbpphp@xxxxxxxxx> 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/
>

I'll second the PDO thing, with parameterised queries. It's really the only way of decently protecting against injection attempts. 

It also does mean that you learn how to do things in the PDO way, and many frameworks use this under the hood, so it's good to know. 

As for not being able to do everything, PDO covers the majority of things in MySQL that you care to throw at it, and personally I've only ever found a couple of times where I was limited in how to accomplish something. 
-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux