0

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
:)

5
Contributors
9
Replies
10
Views
5 Years
Discussion Span
Last Post by hakeemtunde
0

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?

0

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 :)

1

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!

Votes + Comments
My thoughts exactly
0

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 :)

0

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).

Edited by pritaeas: n/a

0

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!

0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.