mysqli - Use the class (OO) or functions?

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
User avatar
Kev
Forum Newbie
Posts: 21
Joined: Tue Aug 25, 2009 9:11 pm

mysqli - Use the class (OO) or functions?

Post by Kev »

Hi Guys,

I'm switching to using the mysqli extension (coming from mysql) and can't quite figure out how one should decide whether to use the OO mysqli approach or the procedural mysqli approach. I've done some searching and research, but haven't been able to figure out what advantages one might have over the other. I tend to mix my scripts with OOP and procedural code, so it's not like I usually code one way or the other. I'd also like to know which approach you take.

Thanks for your advice and guidance!

Kevin
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: mysqli - Use the class (OO) or functions?

Post by Eran »

MySQLi is OO based in nature but also allows for procedural style, to ease the migration for people more used to it. You should use the syntax that integrates the best with your own source code, there is no specific advantage to using one over the other (though I think not all OO methods are available as functions as well).
Post Reply