Calendar
QuicksearchArchivesCategoriesGet Jimdo!Get a free website with professional content management features at Jimdo.com!
|
eZeAR_ActiveRecord implementationSaturday, June 24. 2006Comments
Display comments as
(Linear | Threaded)
"The most viable option for PHP5 clearly is Propel. Without a doubt, it's the most advanced ORM layer out there"
You never have a look at EZPDO then did you? In my point of view that is a much more beautiful piece of code and definitely worth a look.
By the way your AR implementation looks pretty good, although you might want to improve the find-syntax.
EZPDO must've slipped under my radar - from a quick glance over their docs I don't think EZPDO and Propel are directly comparable, though. EZPDO seems to focus on dynamically generating the database schema from the classes you write - Propel (and most other PHP-based ORM solutions) work the other way round: You first create your database schema, then generate or write classes that represent one table each.
As I like to design my own schemas, I'll stick to the latter approach
EZPDO is nice but SLOW. The beauty is offset but the insane number of backend queries needed to do simple tasks.
I am not sure how that relates to Propel, as I haven't used it recently.
The thing I don't like about Propel is that it has a build stage and that simply isn't agile enough for me. EZPDO also has a build stage but you have the possibility to automatically rebuild at runtime when running the scripts in your development environment and that removes all the pain. Unfortunately I haven't found this possible in Propel.
"The idea of using the docblocks for meta information is nice though, but I wouldn't want to use that at runtime."
You did notice that the docblocks are only used when the model classes are generated?
Yeah I did notice, I just wrote that because I wouldn't want to it that way in my implementation, at least not if I keep doing everything at runtime.
There was an article in phparch about ezPDO, DB_Dataobject and Propel (I think) but I do not recall the conclusion of the article.
ezeAR has no bearing with the ezComponents or does it ?
Actually, no, hasn't, at least not directly
This looks like my active record implementation. Mine had to be php 4 compatible at the time of writing, so extending zend framework was not an option. But in a year or so I may swith to a more powerfull implementation like yours.
Good luck with this ! Active record is a great pattern.
Source is at : http://svn.berlios.de/wsvn/thinkedit/trunk/class/record.class.php?op=file&rev=0&sc=0
And a test is at : http://svn.berlios.de/wsvn/thinkedit/trunk/test/record.test.php?op=file&rev=0&sc=0
This is from a cms I'm curently building. (thinkedit.org)
Hi,
This looks like quite a clean implementation. Obviously I'm a little biased on implementation (I'm lead on Propel), but I certainly think there's room in the PHP world for some AR implementations in addition to metadata-driven solutions like Propel and Manuel's Metastorage.
I should point out that Propel 2 (the in-development version) uses PDO instead of Creole. (There wasn't a decent abstraction layer for PHP 5.0.x, which is why Creole exists.)
In any event, I look forward to seeing the development of this product.
Hans
Good to hear that - I'm very curious about what you guys come up with next for Propel
I set the stylesheet on the subversion respository so directory listing looks better than before. PHP files are not syntax colored though.
This is the most ugly piece of code that I saw in the last year!
Starting with the name you choose: eZeAR_ActiveRecord witch is quite hard even to remember.
Also, you are using php 5 syntax like, but can you plese remember to remove all the "call by reference stuff" (yeah, I'm looking at &save() method) since in php5 there is no need for that?
Moreover you are prefixing methods with _ (to mark your method as beeing private/protected), how can you read that loud (
protected function UNDERSCOREpopulate $row ) ?
How often do you read code outloud to other people ?
Anyway, writing private methods with an underscore does make code more readable. For protected it is mostly a matter of taste/choice.
Calling the code most ugly is going over the top since the class name can easily be changed and the "call by reference stuff" can be fixed easily as well if need be.
Regarding the class name, I see his point - after typing eZeAR a few times now, I'm starting to get annoyed by it, so I'll probably change the prefix to something simpler.
About the &'s, well, old habits die hard. And the underscores, well.... it's a quite common practice for naming private/protected stuff and I'm trying to keep close to PEAR coding standards. Aside from that, I think it's appropriate to quote the immortal words of William Shatner: "Get a life!"
Because you blog has a nice visibility since it's on planet, I think you should try to promote php best practices instead of kissing php group asses.
So, instead of prefixing your php classes you should promote namespace addition in php.
A lot of n00bs will probably read you articles, so take care about &'s because one day the SPL guy will do a commit by mistake where he will remove & from language, or convert this to a syntax error.
Since I'm a full time rails programmer let me annonce you that I have a beatiful life
Because my blog has a good visibility since being aggregated on PHP-Planet I have an obligation to write only the best possible code to not confuse newbies?
Sure. And since polititians have a high public influence, they must always tell the truth or know what they're actually talking about? And I suppose because Newspapers are available at every street corner, the articles they're printing must not contain false information and everything has to be properly researched? Take a close look at reality - things aren't what you'd like them to be
On the optimisation front markus you may want to read http://blog.libssh2.org/index.php?/archives/28-How-long-is-a-piece-of-string.html#extended
Quote:
You can still avoid 90% of the INIT_STRING/ADD_STRING dilema by simply using single quotes and concatenation (or commas when dealing with echo statements). It's a simple trick and one which shouldn't harm maintainability too much, but on a large, complicated script, you just might see an extra request or two per second.
Have you checked out Doctrine ? I would argue its the most advanced feature-wise ORM solution availible for PHP. Its not as mature as Propel yet but its under constant development.
svn: svn.phpdoctrine.org
trac:
trac.phpdoctrine.org
site:
www.phpdoctrine.com
I very much like your ideas of keeping the code free of userland abstraction layers and column names built right into the classes as hard-coded properties - both for speed.
Keep up the good work!
|
Recent CommentsThu, 12.02.2009 13:12
I am not sure I will be able t
o make it on either weekend.
Go for either weekend and I wi
ll see if I am in the ar [...]
Tue, 20.01.2009 18:32
In den letzten Wochen sind in
diversen englischsprachigen Bl
ogs sehr interessante und teil
weise recht ausfhrliche [...]
Tue, 13.01.2009 13:40
Well I am mostly at fault for
the "complexity". I actually u
sed pretty much all the advanc
ed features in real worl [...]
Mon, 05.01.2009 10:24
I agree completely: KISS.
S
ince rights management can be
complicated, I find it works b
est when you push it dow [...]
Mon, 03.11.2008 23:58
Hi! Are you planing to share t
he slides of your talk? TIA!
Sat, 25.10.2008 10:13
Am nchsten Montag (27.10.) beg
innt die 14. Internationale PH
P Konferenz in Mainz und luft
bis zum Freitag (31.10.) [...]
Entry's Links
Content license |
|||||||||||||||||||||||||||||||||||||||||||||||||
Let me start this post with the announcement that even before the first official release of my own set of components, I've already changed their name, or their namespace prefix, if you will. As someone who commented on one of my previous entries has point
Tracked: Jul 02, 02:54