From 9d73048be98cab0ed44b82cff6b832384b49cb74 Mon Sep 17 00:00:00 2001
From: Qiang Xue <qiang.xue@gmail.com>
Date: Tue, 7 Jan 2014 09:50:37 -0500
Subject: [PATCH] Fixes #1791.

---
 framework/yii/db/ActiveQuery.php | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/framework/yii/db/ActiveQuery.php b/framework/yii/db/ActiveQuery.php
index f87422a..d2890dd 100644
--- a/framework/yii/db/ActiveQuery.php
+++ b/framework/yii/db/ActiveQuery.php
@@ -249,7 +249,13 @@ class ActiveQuery extends Query implements ActiveQueryInterface
 
 		if (!empty($with)) {
 			foreach ($with as $name => $value) {
-				$this->with[$name] = $value;
+				if (is_integer($name)) {
+					if (in_array($value, $this->with, true)) {
+						$this->with[] = $value;
+					}
+				} elseif (!isset($this->with[$name])) {
+					$this->with[$name] = $value;
+				}
 			}
 		}
 
--
libgit2 0.27.1