Re: Mysqli support - test or complain?

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

 



On Monday 10 December 2007, Dave M G wrote:

> One is based on the assumption that mysqli is as likely not to be
> available as it is to be installed. In this case I should write my
> scripts to test whether it exists and then use either mysqli or straight
> mysql commands as appropriate. If this is the way to go, what do I do to
> test for the existence of mysqli from within a PHP script?
>
> The other is to assume that recent installs and upgrades of PHP > 5
> should have mysqli because that's the currently preferred way of doing
> things, and therefore I should contact the web host and ask that they
> install it, or I find a different host.
>
> Which assumption should I be proceeding with?
>
> Thank you for any advice or assistance.
>
> --
> Dave M G


ext/mysqli is not part of the stock install of any version of PHP.  Some 
shared hosts install it, some do not.

PDO, as of PHP 5.1, is part of the stock install.  Nearly any shared host that 
has MySQL will install the PDO-MySQL backend driver.  I'd say this is the 
most likely MySQL connection method you'll find on a modern host.  (A host 
that doesn't offer PHP 5.2 or later by default is not one you want to do 
business with.  http://gophp5.org/ )

ext/mysql used to be part of the stock install of PHP, but has not been since 
PHP 5.0 for assorted legal reasons.  Most shared hosts install it anyway for 
legacy support, but you shouldn't use it because it hasn't had any worthwhile 
updates since MySQL 3 or so.  Securing queries in PDO or mysqli is far far 
far easier.

My recommendation is to use PDO rather than mysqli if you don't control the 
server configuration.  If you can be choosy about the host, then write what 
you want and only pick hosts that will support you.  

Even better, if you are able to do so, write your own thin abstraction layer 
that uses PDO or mysqli internally.  Then you can switch from one to the 
other more easily if you find you need to, and you can also add whatever 
syntactic convenience sugar you want.  

-- 
Larry Garfield			AIM: LOLG42
larry@xxxxxxxxxxxxxxxx		ICQ: 6817012

"If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it."  -- Thomas 
Jefferson

-- 
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