wrong model name error

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');

}



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 !

Extend CActiveRecord with say ‘ActiveRecord’ and override the model method then use ActiveRecord::model()…