Using an ORM solution like Propel
Posted: Fri Mar 30, 2007 10:53 am
I'm not ENTIRELY sure of what I'm doing just yet with OOP PHP, but I'm trying my best to do things the right way. Previously, I had a number of functions used in various places throughout the application. I kept them in common libraries that were accessible through the _autoload function. The details of the project are somewhat irrelevant for my question I think.
I've now moved to an ORM solution, Propel specifically. I've created used it to create classes for each of my database tables. I'm not really sure how I work with this now. When I'm adding new functionality to the system, do I add to the classes that Propel has created? For instance, I have a function to find out if there are duplicate users. It does a simple select statement and returns true or false. Does it make sense to leave this as separate function or should I add it as a function to the Propel User class?
If I were to add it to the Propel classes, each time a user was registering with my application I would create a new user with their ID and then do something like if($user->isDuplicateUser()) then { $shoutAngrily->atPeople(); } Otherwise, I'd just leave it as a function outside of the class. Does it make sense to add functions like this to the classes propel has created for me or would that be some sort of class bloat? Thanks for any and all help.
I've now moved to an ORM solution, Propel specifically. I've created used it to create classes for each of my database tables. I'm not really sure how I work with this now. When I'm adding new functionality to the system, do I add to the classes that Propel has created? For instance, I have a function to find out if there are duplicate users. It does a simple select statement and returns true or false. Does it make sense to leave this as separate function or should I add it as a function to the Propel User class?
If I were to add it to the Propel classes, each time a user was registering with my application I would create a new user with their ID and then do something like if($user->isDuplicateUser()) then { $shoutAngrily->atPeople(); } Otherwise, I'd just leave it as a function outside of the class. Does it make sense to add functions like this to the classes propel has created for me or would that be some sort of class bloat? Thanks for any and all help.