perl5-dbi/DBD-MariaDB

Backward compatibility with DBD::mysql

greyhard opened this issue · 1 comments

Hello, why you break a compatibility with DBD::mysql
i mean mysql_insertid => mariadb_insertid and else mysql_* to mariadb_*
because i need refactor whole app to use you driver

pali commented

Hi!

The attribute mysql_insertid is a private attribute name for a DBD::mysql driver because it starts with a mysql_* prefix. You can look into the DBI documentation about this naming: https://metacpan.org/pod/DBI#private_your_module_name_* Basically this is the only thing which DBI driver can do to not cause any conflicts in DBI/DBD namespaces or other problems.

Moreover registering mariadb_ private prefix for DBD::MariaDB module was added in this DBI pull request https://github.com/perl5-dbi/dbi/pull/56/files which is now part of last released DBI version. Looking at the code around you can see that for every prefix there is registered one correspondent DBD module.

Anyway, you should use driver aware DBI method last_insert_id https://metacpan.org/pod/DBI#last_insert_id instead of mysql private attribute mysql_insertid which works only with the mysql driver and its databases. It is always a good idea to not bound application code to one specific driver or database if you already have API/framework which abstract it.