vekap
(Vedran Kapetanovic)
1
Hi,
I have the following code
$model = CActiveRecord::model($_POST['m']')->findByAttributes(
array(
'no' => (int)$_POST['no'],
));
Now, here comes the problem…
if $_POST m has any other value than any existing model, I get the following error
–
include(ValueOfM.php): failed to open stream: No such file or directory
–
So the questing is how to modify (not to say disable) this error ?
I’ve tried with try/catch but it doesn’t work neither…
try{
$model = CActiveRecord::model($_POST['m']')->findByAttributes(
array(
'no' => (int)$_POST['no'],
));
}catch(CHttpException $e) {
throw new CHttpException(404, 'blablabla');
}
mdomba
(Maurizio Domba Cerin)
2
Why would you disable the error…
It would be better to sanitize the $_POST[‘m’] value so that you are sure it something you can use…
And in the code you have an error in model($_POST[‘m’]’) - the last single quote !
jayrulez
(Waprave)
3
Extend CActiveRecord with say ‘ActiveRecord’ and override the model method then use ActiveRecord::model()…