I suspect that because PDO is expecting an integer, it’s using PHP’s type conversion functions to change that string into an integer. PHP will just take the leading digits and ignore any remaining junk, so in your case, it’s taking the 1 from the beginning and ignoring everything else.
You can see how PHP converts strings to numbers here.
My point is, if the person using your API has access to the record with ID 1, then it doesn’t matter whether they pass the number or that string. No changes are being made.
When updates are performed, each field that can be massively assigned is validated to prevent any badly formatted values. There is no risk when simply fetching the record.
Validators are not used (for this very reason) when fetching records.
The simplest option is to validate the value in your action, as the model isn’t designed to do what you’re attempting.
if you created your crud with gii it will provide you with performAjaxValidation method in your controller you can comment that and in your model you can add the rules you need as simple as that
$this->performAjaxValidation($model);
/**
* Performs the AJAX validation.
* @param Post $model the model to be validated
*/
protected function performAjaxValidation($model)
{
if(isset($_POST['ajax']) && $_POST['ajax']==='post-form')
{
echo CActiveForm::validate($model);
Yii::app()->end();
}
}