From daf6c81f27a943948f38cd7e70f81917d0a97d19 Mon Sep 17 00:00:00 2001
From: Qiang Xue <qiang.xue@gmail.com>
Date: Tue, 7 Jan 2014 08:58:13 -0500
Subject: [PATCH] Fixes #1791

---
 framework/yii/db/ActiveQuery.php | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/framework/yii/db/ActiveQuery.php b/framework/yii/db/ActiveQuery.php
index 068c713..f87422a 100644
--- a/framework/yii/db/ActiveQuery.php
+++ b/framework/yii/db/ActiveQuery.php
@@ -243,10 +243,16 @@ class ActiveQuery extends Query implements ActiveQueryInterface
 					unset($with[$name]);
 				}
 			}
-			$this->with($with);
-		} elseif ($eagerLoading) {
-			$this->with($with);
+		} elseif (!$eagerLoading) {
+			$with = [];
 		}
+
+		if (!empty($with)) {
+			foreach ($with as $name => $value) {
+				$this->with[$name] = $value;
+			}
+		}
+
 		return $this;
 	}
 
--
libgit2 0.27.1