protected static findByCondition ( mixed $condition ) : yii\db\ActiveQueryInterface | ||
$condition | mixed | please refer to [[findOne()]] for the explanation of this parameter |
리턴 | yii\db\ActiveQueryInterface | the newly created [[ActiveQueryInterface|ActiveQuery]] instance. |
protected static function findByCondition($condition)
{
$query = static::find();
if (!ArrayHelper::isAssociative($condition)) {
// query by primary key
$primaryKey = static::primaryKey();
if (isset($primaryKey[0])) {
$condition = [$primaryKey[0] => $condition];
} else {
throw new InvalidConfigException('"' . get_called_class() . '" must have a primary key.');
}
}
return $query->andWhere($condition);
}