hi,
i have a class file that have all values from a database fields.
for example:


class mospedidos extends mosDBTable {
id = null;
date =null;
}

class mosunder extends mosDBTable {
id = null;
name =null;
}

each time i creat a new field in the database i need add the same field in the
class file, what i want is a way using php to add that new field to the class file.
i just need a way to open the file and the class name that i give and add the value
and save the file.
how can i do this?
thanks for your help
:)

Recommended Answers

All 9 Replies

Member Avatar for diafol

You could have an include file I suppose. Is there any reason why your DB needs redesigning so often?

Would an ORM be any use, like Doctrine?

hi,
the app is growing and everyday i must add new fields.
i have seen your sugestion thanks for that but i looking for a more simple way
to do this, i just want a php script to open the class file and open the class that i request and add the new value that i say.
thanks :)

hi,
the app is growing and everyday i must add new fields.

App growing or bad design? App growing should at worst add new table not alter a table.
I think it is time to check your design!

commented: My thoughts exactly +14

evstevemd i agree with you.

hi,
i don´t think it´s bad design because
each week a new person ask about a new function or fields that don´t already exist :)

If the class is a one off copy of the table, why not let the class load it's columns and default values from the table. See the mysql manual for more information.

From the PHP side, I suggest you ditch your class properties, and switch to the __get() magic method.

Even in an agile development environment, they will not have database changes each week. Not necessarily bad design, but definitely bad management (IMHO).

hi,
i don´t think it´s bad design because
each week a new person ask about a new function or fields that don´t already exist :)

What kind of application is that? Definitely it is bad design. You cannot take toyota Mark II blue print and add new feature and say there was no design shortage. I don't want to enter into arguments but it is either bad design or it is entirely new app I have never heard of!

and if you mean a library where one can add nore functionality then check with inheritance!

srdva59 you shouldn't feel bad about the post but all means the fact. You can be more elaborate about your design may be someone might have a better idea.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.