Procházet zdrojové kódy

ZF-10589
Fixed type issue with params in having() and orHaving() inside Zend_Db_Select


git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@23236 44c647ce-9c0f-0410-b52a-842ac1e357ba

ralph před 15 roky
rodič
revize
7dbcd8720e
2 změnil soubory, kde provedl 15 přidání a 2 odebrání
  1. 2 2
      library/Zend/Db/Select.php
  2. 13 0
      tests/Zend/Db/Select/StaticTest.php

+ 2 - 2
library/Zend/Db/Select.php

@@ -532,7 +532,7 @@ class Zend_Db_Select
      */
     public function having($cond, $value = null, $type = null)
     {
-	    if ($value) {
+        if ($value !== null) {
             $cond = $this->_adapter->quoteInto($cond, $value, $type);
         }
 
@@ -559,7 +559,7 @@ class Zend_Db_Select
      */
     public function orHaving($cond, $value = null, $type = null)
     {
-        if ($value) {
+        if ($value !== null) {
             $cond = $this->_adapter->quoteInto($cond, $value, $type);
         }
 

+ 13 - 0
tests/Zend/Db/Select/StaticTest.php

@@ -603,6 +603,19 @@ class Zend_Db_Select_StaticTest extends Zend_Db_Select_TestCommon
 	}
 
     /**
+     * @group ZF-10589
+     */
+    public function testHavingZero()
+    {
+        $select = $this->_select()
+                       ->columns(array('count' => 'COUNT(*)'))
+                       ->group('bug_id');
+
+        $select->having('COUNT(*) > ?', 0);
+        $this->assertEquals('SELECT "zfproducts".*, COUNT(*) AS "count" FROM "zfproducts" GROUP BY "bug_id" HAVING (COUNT(*) > 0)', $select->__toString());
+    }
+
+    /**
      * Test adding an ORDER BY clause to a Zend_Db_Select object.
      */