Skip to content
This repository
Browse code

Merge pull request #526 from woodspire/IsInteger

Add IsInteger function to ColumnMap
  • Loading branch information...
commit 894e89dd338e6a8bdc04d5db6cbad6c9eeda3b30 2 parents 918cd5f + 7bc0414
William Durand authored December 04, 2012
10  runtime/lib/map/ColumnMap.php
@@ -212,6 +212,16 @@ public function isNumeric()
212 212
   }
213 213
 
214 214
   /**
  215
+   * Whether this column is an integer
  216
+   *
  217
+   * @return boolean
  218
+   */
  219
+  public function isInteger()
  220
+  {
  221
+    return $this->getPdoType() === PDO::PARAM_INT;
  222
+  }
  223
+
  224
+  /**
215 225
    * Whether this column is a text column (varchar, char, longvarchar).
216 226
    * @return     boolean
217 227
    */
10  test/testsuite/runtime/map/ColumnMapTest.php
@@ -149,4 +149,14 @@ public function testIsPrimaryString()
149 149
       $titleColumn->setPrimaryString(true);
150 150
       $this->assertTrue($titleColumn->isPrimaryString(), 'isPrimaryString() returns true if set.');
151 151
   }
  152
+
  153
+  public function testIsInteger()
  154
+  {
  155
+      $bookTable = BookPeer::getTableMap();
  156
+      $idColumn = $bookTable->getColumn('id');  // INTEGER
  157
+      $titleColumn = $bookTable->getColumn('title');  // VARCHAR
  158
+
  159
+      $this->assertTrue($idColumn->isInteger(), 'isInteger() returns true');
  160
+      $this->assertFalse($titleColumn->isInteger(), 'isInteger() returns false');
  161
+  }
152 162
 }

0 notes on commit 894e89d

Please sign in to comment.
Something went wrong with that request. Please try again.