Forum Moderators: coopster & phranque

Message Too Old, No Replies

MySQLi for Perl

         

csdude55

8:41 am on Nov 22, 2020 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



As I'm transitioning all of my PHP to use MySQLi instead of MySQL (mainly so that I can update to PHP 7.x), I realize that I can't find anything for Perl to use MySQLi.

I'm currently using the DBI module to access MySQL:

[metacpan.org...]

Is there an option to change it to MySQLi? Either way, is there any real advantage in doing so? I have to assume that there is since PHP 7.x is forcing my to rewrite everything to switch... surely it's not arbitrary?

Dimitri

9:21 am on Nov 22, 2020 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member Top Contributors Of The Month



MySQLi is a PHP extension. It's just a series of functions to access a MySQL server. Perl has nothing to do with it, you do not need to change your Perl scripts.

JorgeV

12:38 pm on Nov 22, 2020 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member Top Contributors Of The Month



Hello,

As mentioned by @dimitri , MySQLi is just a library for PHP, it replaces the previous MySQL PHP library because it's "improved" (the "i"), so PHP depreciated the former MySQL PHP library.

That being said, if you are in a process of rewriting / reviewing your code , you should use the PHP PDO class [php.net...] , this is safer and more future proof . The PDO class provides a series of function to do any kind of DB manipulations, and it independent from the DB engine. So , for example, if one day, you decided to switch from MySQL to another DB engine, you'll be able to keep your code, and just change the db engine, when you create the PDO object.

phranque

1:10 am on Nov 23, 2020 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



technically speaking, DBI is perl's DB-independent interface and DBD::mysql is the mysql-specific interface.
therefore PHP's MySQL(i) is more equivalent to DBD::mysql than to DBI.