In my college days I remember a php code that handles errors like this..
$rs = $mymodel->find("usr=:usr",array("usr"=>"mahan")) on error echo $mymodel->geterror();
but i know the code above is wrong…
It’s an error handling code I could not remember anymore..
maybe you would suggest something like this
/**First code suggestion**/
if(!mymodel->find("usr=:usr",array("usr"=>"mahan"))){
$rs = mymodel->find("usr=:usr",array(":usr"=>"mahan"));
}
or like this
/**Second code suggestion**/
try{
$rs = mymodel->find("usr=:usr",array("usr"=>"mahan"));
}
catch(Exception $e){
dump($e);
}
My problem is I don’t want to repeat the same operation just to test it if it will have errors(shown on the first code suggestion).
And the second code suggestion doesn’t work.
the error handling I shown on very foremost of my question is wrong but I think it would solve my problem(I just don’t remember the right one)… if not tell me your suggestions.
I’m using Yii Framework
Don’t understand where you hit the road block because you can still assign to a variable:
So there is no need to execute the same function again.