Re:Epiphany, a RESTful micro PHP framework I wrote/use for m...
by AlexMuir on Friday December 10, 2010 @05:29PM
(#1993443)
I've got you, but I'm wondering what your approach is? I'm stuck in a mindset where I work from creating a database to CRUD to functional code.
Re:Epiphany, a RESTful micro PHP framework I wrote/use for m...
by jmathai on Friday December 10, 2010 @05:53PM
(#1993525)
I write the CRUD statements but only as I need them. For a lot of my tables I never intend on deleting records so a delete method never gets written.
If I need to do a SELECT on a specific field(s) then I write that statement. It's usually a 4 line function in a class that deals primarily with that table (but not necessarily as it may make sense in a different class).
I use static functions for that as well.
class User {
public static function getByEmail($email) {
return getDatabase()->one('SELECT * FROM user WHERE email=:email',
array(':email' => $email));
}
}
I don't typically end up with so many of those that it's unmanageable and writing it takes about 30 seconds.That's my approach. What's your thought on that coming from the mindset that a lot of that is taken care of by the framework? I'm curious since that's not a mindset I've had yet.
If you prefer than then I do think the larger frameworks are a good fit. What I'm saying is that I don't prefer that :).