I heard a lot of good stuff about ORM Doctrine. I can put lot of effort learning Doctrine using a great tutorial like http://www.phpandstuff.com/articles/codeigniter-doctrine-from-scratch-day-1-install-and-setup, but it is quite outdated and is using Doctrine 1.x. I prefer learning Doctrine 2.x immediately in order to save time.
I managed to install Doctrine 2.1 in combination with Codeigniter 2.0.3. I've already managed to do some basic operations like adding new objects and save them to the database. Now I'm trying something that shouldn't be too difficult, but I've spent quite some time to find out how to do the following:
In case I want to create an object using $_POST data, I don't want to assign every property separately in code. I'd prefer something like $u->fromArray, e.g. as shown in
$data = array(
'username' => 'myuser',
'password' => 'mypass',
'email' => '[email protected]'
);
$u = new User();
$u->fromArray($data);
$u->save();
Source: http://www.phpandstuff.com/articles/codeigniter-doctrine-day-5-database-crud
However, fromArray() doesn't exist in Doctrine 2.x anymore. Is there an equivalent for fromArray() in Doctrine 2.x?
Second question: I find it pretty hard to get started. The official documents focus mainly on Doctrine. It would be very nice to have a practical example that includes things as form validation, crud operations etc. It would be very nice to have a MVC example project using Doctrine 2. Does anyone know of such a tutorial or example project?