Junior Grossi wrote: > Hi all, > > I've read the book 'Practical Web 2.0 Applications with PHP' and in > that book the author uses a different database modeling. > I'll give you an example, if you have a 'users' table with a lot of > columns like, first name, last name, country, food, etc... He suggests > that you create 2 tables, called 'users' and 'users_profile": > > - users table: > user_id > username > password > ... > > - users_profile > user_id > profile_key > profile_value > > So... if you have to insert the user's country, you insert into > users_profile table: (7162, 'country', 'brazil')... > > So, the author give us two classes to manipulate the user object and > profile (DatabaseObject and Profile classes). > If you want to get the user's country you use: > > $user = new DatabaseObject_User(); > $user->load(7162); //the user id > echo $user->profile->country; //will print 'brazil' > > It's good because you can insert a lot of information without change > the database table.. only adding a new property in the user class. > > What do you think about this new modeling? Have you used this? > Detail: if you have to sum double numbers, for example, the mysql did > the sum normally. > > Thanks. > > Junior Grossi > [EMAIL PROTECTED]
20081012 1306 GMT-6 I have something similar lately and it too relied heavily on objects (which I have to admit I have not really got into - though I should) and it looked like it would definitely help out in certain situations. But Im not sure I understand what you said about not changing anything to the db table. If you didnt already have a field for country and then wanted to add it later, as I read what you just wrote you would changed the db at all - but that cant be can it since you have to have a place to put that value? Wade