[Catalyst] ->model-> return values?

John Napiorkowski jjn1056 at yahoo.com
Sun Sep 24 04:25:23 CEST 2006


-- "Roderick A. Anderson" <raanders at acm.org> wrote:

> I'm 'looked-out'  Been searching and reading for the
> last two hours with 
> no good results.
> 
> A pointer/suggestion/clue-stick would be
> appreciated.
> 
> Do I need to wrap a
> 
> 	$c->model( 'TheModel' )->update( ... )
> or
> 	$c->model( 'TheModel' )->delete( ... )
> 
> in an eval block to check for success or failure or
> ( hope, hope, hope ) 
> can I just test the return value?
> 
> If the return option is valid what would be returned
> on success or failure?
[snip]

I've found that if the update fails for some reason I
get kicked out to the default catalyst error screen.
So I guess you need the eval.  Not sure though, but
that's what I do and it seems to work.

However finds and search seem to return something that
evaluates to false if they don't return results, so I
can do:

$c->model->find({id=>$query}) ||
$c->response->redirect('/errors/not_found');

Not sure if that is the best thing to do, but it's
worked for me :)

--john

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the Catalyst mailing list