Development > Coding and development discussion

Proposed MySQL.php changes

(1/2) > >>

Khalem:
I currently have one major issue with the MySQL layer we use, the fact that you have no way of determining if there was an error based on the return from the MySQL functions. Sure, the error function kicks in and dumps the error to file, but the calling function has absolutely NFI.

Now this isn't the biggest of problem usually, until you start doing things where you depend on the query actually going trough, raid points and joins being one such instance.
If the player doesn't actually get added to the raid, that's a big problem as 1) he will never know 2) there wont even be an error logged 3) he wont get points when the time comes.

Theres currently the returnQuery to allow for this as an alternative to query function, but its not widely used, nor am i entirely satisfied with the fact that all the error handling and parsing will then have to be done inside the function which ultimately means you'll have loads of repetitions.

The real question at this point is, should one merely enhance the returnQuery to return an array (see the new get_site for a demonstration), thus doing all the repetitive error handling in the MySQL layer, or should one do this for all the functions so that even SELECT can benefit from proper error returns. Right now the select function does not differentiate between an empty result and an error as far as the calling function is concerned. The downside is that such a change will break ALL current select calls and will require modifications.

I feel its a small price to pay to get consistent error handling across the line though even if it breaks backwards compatibility.
Were gonna end up breaking 0.2 module compatibility anyways due to the new hooking.
So while we are breaking stuff, we should take advantage of trying to fix as many broken things as possible so that we don't have to keep breaking backwards compatibility later on if it can be avoided.

Alreadythere:
Returning an array with values and errorcode instead of just the values won't involve much modification. We'll just have to change all calls to $result (or whatever the variable for the return is called) to $result['return']. Or something similar.

Or if the result is used too often, use a temp var for the return value, and set the old var afterwards to the array.

Basically I don't see any reason not to add decent error codes.

Even though I usually don't get any errors or warnings after the initial testing.

Khalem:
It's not a hard modification to do in terms of the modules, just extensive :)

Alreadythere:
If something like my tablename functions are added, all db calls have to be modified anyways.

Khalem:
Tablenames are going in as soon as i get around to it, and yes, my thoughts on MySQL error handling have been one of the reasons i haven't done it yet.

Navigation

[0] Message Index

[#] Next page

Go to full version