Advantages vs. Disadvantages of ActiveRecord
Posted: Sun Jun 24, 2007 2:11 pm
Weirdan | Please use
Cheers,
Jacob
Weirdan | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hello!
I've been trying out some ActiveRecord/ORM implementations (Propel, Doctrine ...) recently and somehow came to the following result.
The disadvantages are that ..
... whenever it comes to complex queries it's not possible to use these tools or they make everything even more complex.
... instead of quickly defining tables in well-known SQL syntax this has to be done in PHP itself or in some other language like XML.
... I can't tune my queries, although optimization is not needed very often, I was faced with some cases where it was and these ORM frameworks where simply not flexible enough
... although the standard queries are RDBMS independent you often need to specify additional conditions which then are not!
... to be continued ...
The advantages I see are
... that simple updating/deletion/selection is very easy and makes the code more readable as you don't have to analyse the sql query, instead you just see a function like ->save()
... it looks cool and is RDBMS independent, however how often do you really change you database system and there are really only a few applications that require this.
... it can make development really fast (but sometimes also slow down)
... to be continued ...
Although I'm new to devnetwork I saw that there are some really intelligent and experienced people knowing what they are talking about . So I would like to hear you opinions and experiences with ORMs please.
Is it worth using such tools and what do you think about the way Zend_Db is implemented. I personally think it just sucks because it's half sql and half orm, but not really something .
e.g.Code: Select all
$data = array(
'created_on' => new Zend_Db_Expr('CURDATE()'),
'bug_description' => 'Something wrong',
'bug_status' => 'NEW'
);
$db->insert('bugs', $data);Jacob
Weirdan | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]