Reputation: 690
I am using select method in yii it gives error "Property "CDbCriteria.:centerId" is not defined"
if (0 < self::model()->countByAttributes(
'centerId = :centerId AND qTypeId = :qTypeId',
array(
':centerId' => $centerId,
':qTypeId' => $qTypeId,
)
)) {
throw new Exception('Duplicate Entry for center and que type');
}
Upvotes: 0
Views: 115
Reputation: 22174
You're using this method in a wrong way. You skipped first argument, which should be list of active record arguments used as filter (see documentation). You probably need something like:
if (0 < self::model()->countByAttributes([
'centerId' => $centerId,
'qTypeId' => $qTypeId,
]) {
throw new Exception('Duplicate Entry for center and que type');
}
Or use count()
:
if (0 < self::model()->count(
'centerId = :centerId AND qTypeId = :qTypeId',
[
':centerId' => $centerId,
':qTypeId' => $qTypeId,
]
)) {
throw new Exception('Duplicate Entry for center and que type');
}
Upvotes: 1