Announcement

  •  » Engine
  •  » usage of php's mysqli instead of mysql

#1 2012-10-08 19:54:58

Matthes0815
Member
2012-10-08
2

usage of php's mysqli instead of mysql

Hello everybody,

I started using piwigo a few weeks ago and I like it. It's not for my photos, since I'm not good at photography, but my girlfriend wanted to display her pictures of our dog and our garden and so on...

I started to develope some extensions because she had some ideas no extension covered yet and tried to switch from the deprecated mysql extension to mysqli.
The first steps were simple, but I discovered some problems that will be very annoying if we update to a new version.

Some extensions don't use the pwg_db-functions for every db-call, so I had to change them. They often used pwg_db_query for the query and worked on the result mysql_fetch_array.
And even the core files use mysql_ at some places, e.g. i.php uses mysql_close() on line 521.

I think it's time to switch to mysqli, add some coding guidelines concerning the usage of pwg_db and complete the pwg_db-functions: pwg_db_close() is missing, for example.

Sooner or later php's mysql-extension will be gone and it would be a lot easier to switch to mysqli if extensions and the core files won't need any revision.

Kind regards
Matthias

Offline

 

#2 2012-10-08 20:15:53

mistic100
Former Piwigo Team
Lyon (FR)
2008-09-27
3277

Re: usage of php's mysqli instead of mysql

Hi

there are guidelines but we can't check all plugins

for errors on the core you can open un ticket at http://piwigo.org/bugs
we'll fix it

if you hadn't noticied yet, for switching to mysqli you can simply duplicate the file include/dblayer/functions_mysql.inc.php
and put $conf['dblayer'] = 'mysqli'; in local/config/database.inc.php

Offline

 

#3 2012-10-08 20:16:47

mistic100
Former Piwigo Team
Lyon (FR)
2008-09-27
3277

Re: usage of php's mysqli instead of mysql

we can't force MySQLi because many hosts don't have the extension

Offline

 

#4 2012-10-08 23:16:05

Matthes0815
Member
2012-10-08
2

Re: usage of php's mysqli instead of mysql

Hi,

thanks for your answer.
I did it this way, copied the functions_mysql.inc.php and added the line into the locale/config/database.inc.php. The code and the file/folder structure is very logical and it wasn't difficult to figure this out - one of the many things I like very much. It's different from some things I was used to, but it's something you get used to very fast.

It's correct that some hosts don't offer mysqli yet, but it would be up-to-date to use it as default setting. It would force the correct usage of the pwg_db-functions and thereby help for future additions of database structures, I think.

I would've reported the usage of mysql_close() inside the i.php, but it's currently not a real bug. As long as piwigo just uses the mysql-extension, it won't be a problem.

There are coding guidelines, but I could not find any guidelines regarding the usage of database related functions. So currently it's ok if everybody uses the standard mysql functions or even some functions build by himself. In my opinion it would only be possible to report it as bug if there were some guidelines to rely on.

It's just what I was thinking about the deprecated mysql extension, there are some advantages in using mysqli, apart from the benefit of correct usage of functions. :)

Matthias

Offline

 
  •  » Engine
  •  » usage of php's mysqli instead of mysql

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2024 · Contact