add values into class file
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
:)
srdva59
Junior Poster in Training
58 posts since Feb 2009
Reputation Points: 7
Solved Threads: 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?
diafol
Rhod Gilbert Fan (ardav)
7,792 posts since Oct 2006
Reputation Points: 1,170
Solved Threads: 1,080
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 :)
srdva59
Junior Poster in Training
58 posts since Feb 2009
Reputation Points: 7
Solved Threads: 0
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!
evstevemd
Senior Poster
3,713 posts since Jun 2007
Reputation Points: 462
Solved Threads: 392
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 :)
srdva59
Junior Poster in Training
58 posts since Feb 2009
Reputation Points: 7
Solved Threads: 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).
pritaeas
Posting Expert
5,483 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
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!
evstevemd
Senior Poster
3,713 posts since Jun 2007
Reputation Points: 462
Solved Threads: 392
and if you mean a library where one can add nore functionality then check with inheritance!
evstevemd
Senior Poster
3,713 posts since Jun 2007
Reputation Points: 462
Solved Threads: 392