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