diff --git a/src/ActiveRecord.php b/src/ActiveRecord.php index c720d94b2..0c0630724 100644 --- a/src/ActiveRecord.php +++ b/src/ActiveRecord.php @@ -411,4 +411,15 @@ private function dumpBsonObject(Type $object) } return ArrayHelper::toArray($object); } + + /** + * using ActiveQuery::exists() method in friendly mode + * @param reference $object if passed then object returned based on conditions , else only checked existence in database + * @return bool return true if $conditions exists in database + */ + public static function exists($conditions, &$object = null){ + if(func_num_args() === 2) + return ($object = self::find()->where($conditions)->one()) ? true : false; + return self::find()->where($conditions)->exists(); + } }