MyBB Community Forums

Full Version: simple_query() vs mysql_query()
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
Do I need to call mysql_free_result() after my queries?
(2011-09-15, 06:42 PM)Masayoshi Wrote: [ -> ]Do I need to call mysql_free_result() after my queries?

$db->free_result();

Is what you're looking for.

EDIT: You don't absolutely have to though, as everything is freed when the script ends. Its primarily done manually to keep memory overhead down when performing a lot of queries and/or large table queries.
Aha! Thanks. Is it mandatory to call $db->free_result(); after each set or only after sets that I am worried about (such as a full selection)?

EDIT: seems my question was answered in the above edit. Toungue

You guys sure are friendly towards the unaware. I wasn't expecting developers themselves to answer any of my questions let alone answer basic ones. MyBB's community is amazing.
Please remember that not all input is escaped and none of the methods in the DB class sanitise your input so make sure you use $db->escape_string or intval, floatval, etc, when placing input variables in a query.
Developers always chip in Wink It really is a great community and their input is pretty useful when the wiki can't help.
(2011-09-15, 07:21 PM)Pirata Nervo Wrote: [ -> ]Please remember that not all input is escaped and none of the methods in the DB class sanitise your input so make sure you use $db->escape_string or intval, floatval, etc, when placing input variables in a query.

Curious though-- why don't you escape/cast the variables through your class? Was there a reason?
(2011-09-15, 07:58 PM)Masayoshi Wrote: [ -> ]
(2011-09-15, 07:21 PM)Pirata Nervo Wrote: [ -> ]Please remember that not all input is escaped and none of the methods in the DB class sanitise your input so make sure you use $db->escape_string or intval, floatval, etc, when placing input variables in a query.

Curious though-- why don't you escape/cast the variables through your class? Was there a reason?

The Mybb 1.x core was written years ago and if that change was ever to be done it should have been in done from MyBB 1.2 to 1.4 but was not done at that time (I do not know why) and right now it doesn't justify do it because many plugins will lose compatibility.

I've turned developer one month ago or so thus I am not qualified enough to answer you things about the past of the development process.
Okay, I can understand your position in the matter regarding the question, I just found it a bit strange that you would go through the trouble of having a class system that handles db queries but only pass it through, would have made sense to do some checking at that point too to prevent errors in incapable mod authors and such.

Overall it's not that big of a deal because I always clean up, out of habit.

I'm in the middle of creating a small plugin, which I'm not going to reveal yet because I want to make sure it's possible to write it. Though, the plugin requires a manual edit, mostly because of the nature of the plugin. How would I go about making the manual edit? Should I use fopen() or file_get_contents, evaluate the file I want to edit, make the changes? Or is there an official way to make core edits (like through a patch system)?
Are you sure you cannot use the hooks system?

In case you're sure about that you should give Plugin Library 4 a try, it's a very nice (non-official) library for plugin developers.
If there's really no other way, requiring manual edits on the admin's end has worked for most plugins here (those that required manual edits, that is). Google SEO, which is safe to say the most popular plugin, rolled that way until eventually a little system was implemented to apply the changes to files directly from the Admin CP, since too many people can't read the documentation. So you might wanna take a look at that.

There's also a Patches plugin available which you could provide a patch for, in case someone is using it and would rather use a patch than manually editing it (or creating the patch themselves).
Pages: 1 2 3