Jump to content

[SOLVED] Usage of mysql vs. mysqli


GarrettW

Recommended Posts

New member here!

 

I've just started writing a CMS (more or less from scratch), and I'm at the point where I'm writing the database abstraction class. (Yes, I'm doing it in PHP 5 OOP.)

 

I've done a search on here for "mysql vs mysqli" and gathered that the general opinion around here is that mysqli is the one to use. I'd agree, especially because I like the OO-ness of it -- but since what I'm writing will be used by people on all kinds of servers, I'm torn over whether I should use mysqli or the older mysql functions.

How widespread is the mysqli extension? I have no qualms about requiring PHP 5 for my script, but if I'm correct, mysqli isn't compiled into PHP by default, so how likely would it be for any given user to have mysqli installed?

Lastly, I've noticed that most big-name PHP packages (including Wordpress) use mysql - so again, is there a legitimate compatibility concern here?

Link to comment
Share on other sites

well, maybe that's not what i was supposed to call it. it's technically not an interface (since it's a class), but "interface" is more of the idea. I'm writing the M in MVC.

(MVC is what I'm trying to achieve - we'll see how close I end up getting :) )

 

and thanks for the recommendations.

Link to comment
Share on other sites

I thought about going that route - but I'd rather write everything from the ground up, so that (1) I know the code intimately and have complete control over it, and (2) I end up learning more in the process.

It is quite an ambitious project that I'm working on, but it'll be good for me. :)

Also, this is my first real encounter with OO-PHP.

Link to comment
Share on other sites

thanks :) I'm sure I'll be around here a good bit in the time to come.

 

also, I was just thinking - I'm not familiar with any "big-name" pieces of PHP software that were built from one of those pre-made frameworks.

Link to comment
Share on other sites

 

Can you suggest any simple package for running the MySql functions instead of the mysql_functions ? I found in some packages, they re written the MySql function by their function names.. Which will give more security.. And also easy for error logging..

Link to comment
Share on other sites

Suppose, we need to run a query, then use the following:

 

mysql_query()

 

But most of the open source package, rewrite this with their MySql function, like this:

 

code_mysql_query($sql);

 


function code_mysql_query($sql)
{
mysql_query($sql);

}

 

 

I wish to find a package which has the complete list of MySql functions like this..

 

 

Link to comment
Share on other sites

 

I don't know the advantages of this method. But some of them, I think:

 

1. Suppose, if I need to log the errors by using my own method during the query execution, then it is possibly by editing a single function. This will helps to time to open all pages which has the mysql code.

 

2. Escaping can be accomplished..

 

 

Link to comment
Share on other sites

I don't know the advantages of this method. But some of them, I think:

 

1. Suppose, if I need to log the errors by using my own method during the query execution, then it is possibly by editing a single function. This will helps to time to open all pages which has the mysql code.

 

2. Escaping can be accomplished..

 

You'd need a bit more sophisticated functions than the one you posted though...

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.