Welcome to Delicate template
Header
Just another WordPress site
Header

Why I switched to Doctrine

March 20th, 2008 | Posted by Michaël in ICT | Symfony | Web Development - (5 Comments)

As I said in my previous post, I would tell more about why I switched to Doctrine. I mainly started to think about the idea when I first heared that we were going to start a new project in Symfony at work. The lead developer decided to go for Doctrine ORM instead of Propel. So I wanted to know why go went for Doctrine. I allready knew that Doctrine is way faster then Propel 1.2 and it has more possibilities, but I just wanted to hear it from him. And I have to admit, he had good arguments.

The verbosity of the Doctine code is way better then Propel. The model mappings (in line of XML files or YAML) are bigger for Propel then for Doctrine, and in Doctrine you can do everything in PHP instead of using external files (consolidated code is a huge plus).

The API of Propel is also “time-consuming”. Check the following Propel code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
$c = new Criteria();
 
$cton1 = $c->getNewCriterion(AuthorPeer::FIRST_NAME, "Leo");
 
$cton2 = $c->getNewCriterion(AuthorPeer::LAST_NAME,
array("Tolstoy",  "Dostoevsky", "Bakhtin"), Criteria::IN);
 
$cton1->addOr($cton2);
 
// add to Criteria
 
$c->add($cton1);
 
$authors = AuthorPeer::doSelect($c);

with this Doctrine code:

1
2
3
4
5
$authors = $conn->query("
 
FROM Author a WHERE a.first_name = ? OR a.last_name IN ?
 
",array('Leo',array("Tolstoy", "Dostoevsky", "Bakhtin"));

Propel doesn’t support his own query definition language like Doctrine, so every query has to be done through time-consuming API calls (and Doctrine also supports a object oriented API, so it is available if you need it). But it gets a lot more uglier if you when you need associations and eager loading in your queries, what can be run smoothley in Doctrine.

Doctrine supports 3 types of inheritance that you find back in Hibernate, where Propel is only limited in single-table-inheritance. This can be very usefull in the implementation of complex systems.

Doctrine support a sort of mixins (this at the act_as_* plugins of ActiveRecord), in a language that doesn’t support mixins :) . Even think about the “event listeners” like the before_save etc methods in ActiveRecord. (long live Rails right )

Doctine even supports migrations, and in the near future, they even will have automatic migrations (change the model definition, run auto-migrate and the DB is updated).

Some other nice features are full text searching, query/result caching, magic finders ($table->findOneByName), etc.

Doctrine is build in a logical way, the pragmatic use of ActiveRecord mixed with the power of Hibernate.

So be honost, I someone would tell you all the above, wouldn’t you just make the switch immediately?!?

Switching to Doctrine

March 18th, 2008 | Posted by Michaël in ICT | Symfony | Web Development - (0 Comments)

This weekend, I decided to give Doctrine a shot. Since Propel is the default ORM layer, I never really looked at Doctrine before. But reading on the subject got me interested. Luckely their is allready a nice Doctrine plugin available for Symfony, so the switch went smooth, without any problems.

I have to admit, that I was losing my mind in the beginning. I had to get used to the new syntax, and all the new possibilities of Doctrine just blew me away.

I made a backup of a running project developed in Propel (1.2) and just started refactoring the schema and chaning the code. It’s been allmost 5 days, and I wouldn’t go back to Propel at all. Even for the 1.3 version (where people say that it is even faster then Doctrine) . There are plenty of reasons why to stick with or switch to Doctrine, and to be honest, even those slightly speed increases of Propel 1.3 just can’t compete with them.

For those that are still not sure, just check out the Doctrine Documentation. You will find everything you want,  with some nice examples. And for some implementations in Symfony, you can download a Doctrine version of Askeet somewhere on the forum (I know it helped me a bit).

The project is going along nicely. I can’t say mutch yet, but I’ll keep you informed when it is  allmost finished. Their is still a lot of work to do, but I’m getting their, and with the help of Symfony and Doctrine, it just can’t go wrong.

Well, it’s been getting late, and after spending 15 hours behind the computer, I want to spent a few hours before the tv screen to relax.

I’ll explain later in detail what made me switch to Doctrine. In the mean time, let me know what you think about Doctrine or Propel and why you are using that specific ORM.

Longing for the summer

March 1st, 2008 | Posted by Michaël in Blog - (0 Comments)

As a lot of people, I’m looking forward to have a nice summer. Some good weather, and everything seems perfectly in order. Get a nice color, a nice sight in the city of all the nice women ( my girlfriend luckely knows I’m trustworthy ).

But besides a passion for ICT and women (specially my girlfriend, a little bit sucking up to here can’t be harmfull), there is a third thing…beautifull cars. That’s why I bought a ’79 Triump Spitfire 1500 TC last year. The idea came when a friend of mine bought a Spitfire Mk4. When I saw it, I was completly away from the nice design. That’s why I wanted to have one too. So the search began, and I got lucky, only after 3 weeks, I had my own Spitfire.

As a lot of oldtimers, there is still some hard work to do, to get the car in a perfect condition. Especially if you don’t want to spend to mutch money on it. But I like a challenge, and with some knowledge about cars, I started to give my beauty a nice makeover. The first thing I had to do, was reviewing the bodywork. That was in a poor condition. The previous owner had allready done the bodywork a few years ago, but it wasn’t done properly. He had covered the hood with “mastiek” like we call it Dutch. But he covered it with too mutch, and becouse of the heat of the engine, it started to crack. Their where also some places where the paint started to come off + a dend in the passenger door. Below, I have posted some pics so you can see the state it was in when I bought the car.

Triumph Spitfire 1500 Pic 1 Triumph Spitfire Pic 2 Triumph Spitfire Pic 3 Triumph Spitfire Pic 4 Triumph Spitfire Pic 5 Triumph Spitfire Pic 6 Triumph Spitfire Pic 7 Triumph Spitfire Pic 8

As you can all see, the car can realy use a new paint job. The interior has had its best time and the hard top needs to be renewed. Well, only the windows need to be renewed, but I bargained for a new one, so I will allways have this one as a spair, once I redo the windows. I didn’t fix the dend, just bought a second hand Spitfire door :) . Also the chrome needs to be redone and also the plastic bumperstops and grill will be replaced with a chrome one. And offcourse, new rimms. So I started to strip the car and remove the old paint.

Triumph Spitfire Pic 9 Triumph Spitfire Pic 10

I didn’t want to do the paint job myself, so I asked someone to do it for me, since that takes a lot a patient, and I didn’t do something like that before. The car is still in the garage, waiting for its paint job becouse the guy wanted to review the car totaly before starting to paint it. I still have to chose the color. I’m going for red again, but haven’t desided on what kind of red. The only thing I know for sure is that I want 2 white racing stripes going from the front to the back of the car, just to give it a better look.

After the body work, I will start redoing the electricity circuits and interiour. So when I get the car back, I will post some more pics and tell about my progress.

Hope you enjoy the pics, I know it is not mutch at the moment, but it will come ;)