[TYPO3-ect] lib/div 1.0 - it's time to say thank you
Jochen Rieger
j.rieger at connecta.ag
Tue Jan 9 11:55:25 CET 2007
Hi Elmar & all,
> Yes, we need to discuss and compare them. I hope somebody takes up and
> guides us through that discussion.
I won't be able to guide but I can report my experiences with cakePHP
which I recently used for an application that originally was planned to
be set up with TYPO3.
In genereal: cake has some amazing approaches that make programming so
nicely easy!
And here we come across Nikolas' points concerning the model's default
methods. In cake, too, they have methods like save(), edit(), delete(),
findAll() etc.
For example saving the data of a submitted form just looked like this in
the controller:
<snip>
function edit($id = null) {
if (empty($this->data)) {
$this->Orderitem->id = $id;
$this->data = $this->Orderitem->read();
}
else {
if ($this->Orderitem->save($this->data['Orderitem'])) {
$this->flash('Data saved.', '/orders.html');
}
}
} // end function edit()
</snip>
You will get the item's data for inserting into the form by
$this->Orderitem->read();
where Orderitem is the model and read a default function of the cake
framework's parent model class.
$this->Orderitem->save(...) saves the submitted data.
In the model you can also define validation options just as class vars:
var $validate = array(
'quantity' => VALID_NUMBER,
'material' => VALID_NOT_EMPTY,
'format' => VALID_NOT_EMPTY,
);
So ... the framework takes care of many things that you (at least I do)
consider as a pain in the a** sometimes.
Another nice thingy is the flash() method which is inherited from the
parent controller class. In case of a successful db query it flashes an
arbitrary message for 3 seconds and then performs a redirect.
Alright I could continue now talking about cake but this won't help too
much. I will follow the discussion and try to contribute my ideas and
experiences in suitable places!
Keep up... I really like your approach.
Cheers,
Jochen
More information about the TYPO3-team-extension-coordination
mailing list