Hehe, good snippet indeed - sounds like forward404If() from symfony ;)

---
Christian "Jippi" Winther
http://docs.cakephp.nu (Unofficial CakePHP API) 
http://logs.cakephp.nu (Unofficial CakePHP IRC log)

-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf
Of rtconner
Sent: 12. juli 2007 18:25
To: Cake PHP
Subject: Tip O' the Day


This is a great little function to drop into your app_controller. I
use it all the time, makes life just a little bit easier. Thought I'd
share it with you all.

        /**
         * @param string $model Proper name of model
         * @param int $id optional primary id of model
         * @return array $data from Model::read()
         */
        function readOr404($model, $id=null) {
                if($id)
                        $this->{$model}->id = $id;
                if($data = $this->{$model}->read()) {
                        return $data;
                } else {
                        $this->cakeError('error404',
array($this->params['url']));
                        die;
                }
        }




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to