Retrieving functions from database in PHP, is it usual?

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
luismartin
Forum Newbie
Posts: 1
Joined: Mon Mar 28, 2011 12:16 pm

Retrieving functions from database in PHP, is it usual?

Post by luismartin »

Hi, I'm new to this forum!

The reason of my post is because I've just moved to a new company and their programming mode is confusing me a lot. I'm used to OOP, and with big projects I tend to use the MVC archietcture. But the programming method in this place is quite different:

It's quite a procedural way, with few objects which use to be huge (lots of properties and methods) and act as the engine. This is not what I most like but I understand it so far. What I don't understand is the reason why many functions are mapped within the database, stored in tables together with the parameters they will accept. Is this a common way to program PHP? They say it's an efficient way to keep track of further changes to those functions and their parameters (they also come from programming on Visual Basic so maybe this is a common practice with this language). When one of these functions must be called, it's retrieved from the DB and called by using call_user_func(). The thing is I don't see the point, and I'd like to know opinions out there about this. And if possible, some tutorial which covers this type of programming.

Any help would be appreciated.
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Retrieving functions from database in PHP, is it usual?

Post by Jonah Bron »

The function names are stored in the database? That's strange, as far as I know. Could you give us a sample of the table, and the code that calls it?
User avatar
Mordred
DevNet Resident
Posts: 1579
Joined: Sun Sep 03, 2006 5:19 am
Location: Sofia, Bulgaria

Re: Retrieving functions from database in PHP, is it usual?

Post by Mordred »

This is ... gross. Just plain ugly and I don't find any justification for doing what you describe. They are retrieving the function names, right? (That's what I infer from you saying they use call_user_func). The only thing that could be worse would be to retrieve the function source code as well (please tell me they don't!)

Run while you can. Are you the junior programmer they were looking for in October? (assuming it's the company whose second and sixth letter in the company name are the same). If so, run double fast. When starting your career it's important to do jobs that would improve your qualities as a programmer. Working in some places can "damage" you more than the money they pay you.
Post Reply