[limb-svn] r7113 - in 3.x/trunk/limb/dbal: src/query tests/cases/non-driver/query

svn at limb-project.com svn at limb-project.com
Fri Jul 11 11:34:58 MSD 2008


Author: serega
Date: 2008-07-11 11:34:58 +0400 (Fri, 11 Jul 2008)
New Revision: 7113
URL: http://fisheye.limb-project.com/changelog/limb/?cs=7113

Modified:
   3.x/trunk/limb/dbal/src/query/lmbBulkInsertQuery.class.php
   3.x/trunk/limb/dbal/tests/cases/non-driver/query/lmbBulkInsertQueryTest.class.php
Log:
-- minor improvement in bulk insert statement

Modified: 3.x/trunk/limb/dbal/src/query/lmbBulkInsertQuery.class.php
===================================================================
--- 3.x/trunk/limb/dbal/src/query/lmbBulkInsertQuery.class.php	2008-07-10 10:02:16 UTC (rev 7112)
+++ 3.x/trunk/limb/dbal/src/query/lmbBulkInsertQuery.class.php	2008-07-11 07:34:58 UTC (rev 7113)
@@ -68,6 +68,9 @@
   {
     $stmt = parent :: getStatement();
     
+    if(!count($this->_sets))
+      throw new lmbException('Bulk insert query does not have any sets to insert');
+    
     foreach($this->_sets as $index => $set)
     {
       foreach($this->_fields as $field)
@@ -78,5 +81,11 @@
 
     return $stmt;
   }  
+  
+  function execute()
+  {
+    if(count($this->_sets))
+      return parent :: execute();
+  }
 }
 

Modified: 3.x/trunk/limb/dbal/tests/cases/non-driver/query/lmbBulkInsertQueryTest.class.php
===================================================================
--- 3.x/trunk/limb/dbal/tests/cases/non-driver/query/lmbBulkInsertQueryTest.class.php	2008-07-10 10:02:16 UTC (rev 7112)
+++ 3.x/trunk/limb/dbal/tests/cases/non-driver/query/lmbBulkInsertQueryTest.class.php	2008-07-11 07:34:58 UTC (rev 7113)
@@ -29,5 +29,26 @@
     $this->assertEqual($arr[1]['description'], 'some other description');
     $this->assertEqual($arr[1]['title'], 'some other title');
   }
+  
+  function testExecuteDoesNothingIfNotSetsSpecified()
+  {
+    $query = new lmbBulkInsertQuery('test_db_table', $this->conn);
+    $query->execute();
+  }
+
+  function testGetStatementThrowsExceptionIfNotSetsSpecified()
+  {
+    $query = new lmbBulkInsertQuery('test_db_table', $this->conn);
+    try
+    {
+      $query->getStatement();
+      $this->assertTrue(false);
+    }
+    catch(lmbException $e)
+    {
+      $this->assertTrue(true);
+    }
+  }
+  
 }
 



More information about the limb-svn mailing list