Вы неправильно используете этот метод. Вы пропустили первый аргумент, который должен быть списком аргументов активной записи, используемых в качестве фильтра ( см. Документацию ). Вероятно, вам понадобится что-то вроде:
if (0 < self::model()->countByAttributes([
'centerId' => $centerId,
'qTypeId' => $qTypeId,
]) {
throw new Exception('Duplicate Entry for center and que type');
}
Или используйте 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');
}