Re: [PHP] Mysqli support - test or complain?



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
.



Relevant Pages

  • Re: assessing winusb potential
    ... I am now pouring over a USB book but the issue is still not clear. ... What prevents the host from ... Please do not send e-mail directly to this alias. ... able to install downlevle (IIRC, ...
    (microsoft.public.development.device.drivers)
  • Re: assessing winusb potential
    ... I am now pouring over a USB book but the issue is still not clear. ... What prevents the host from ... Please do not send e-mail directly to this alias. ... able to install downlevle (IIRC, ...
    (microsoft.public.development.device.drivers)
  • Re: Virtual PC
    ... Once you install the trial software, make sure to change the date to some far distant time in the future to see if it might trigger on a date. ... You could unlock the snapshot to apply updates to Windows or your known good apps and then save another snapshot and then lock that one to prevent accidental pollution. ... if you do system/data backups of your host then you could just restore the VM's directory from your backups. ... I gave up it very quickly because it was clumsy, poorly documented, and I no longer have it in my download directory to look it up to know its name (but then I already had the free version of ShadowSurfer that did the same thing so I wasn't really motivated to find an alternate free "partition virtualizer" (http://wiki.castlecops.com/System_Partition_Virtualization_-_Comparison). ...
    (microsoft.public.windowsxp.general)
  • Re: Virtual PC
    ... Once you install the trial ... if you don't backup your host then you have ... So do you actually have a 2nd license of Windows XP (either a full ... free "partition virtualizer" ...
    (microsoft.public.windowsxp.general)
  • Re: Virtual PC
    ... Once you install the trial ... if you don't backup your host then you have ... So do you actually have a 2nd license of Windows XP (either a full ... use something like ShadowSurfer to return the system back to its prior ...
    (microsoft.public.windowsxp.general)