Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add IsInteger function to ColumnMap #526

Merged
merged 4 commits into from

2 participants

@woodspire

Second try of #520

To be used with symfony/symfony#6150

This simply add a function.

@willdurand
Owner

Hi, thanks for this patch. Could you add a unit test please?

runtime/lib/map/ColumnMap.php
@@ -212,6 +212,16 @@ public function isNumeric()
}
/**
+ * Whether this column is an integer
+ *
+ * @return boolean
+ */
+ public function isInteger()
+ {
+ return $this->getPdoType() === \PDO::PARAM_INT;
@willdurand Owner

The indentation should be 4 spaces and you should use PDO directly, not \PDO

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@woodspire

I do not know what you meant by "identation should be 4 spaces", I indent my function the same way other functions were indented in the file.

@willdurand
Owner
@woodspire

I added a simple test case. ran phpunit and found no problem with it.

@willdurand willdurand merged commit 894e89d into from
@willdurand
Owner

Perfect. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 4, 2012
  1. Used by PR symfony/symfony#6150

    Felix Labrecque authored
  2. @woodspire

    changed \PDO to PDO

    woodspire authored
  3. @woodspire
  4. @woodspire

    fix typos

    woodspire authored
This page is out of date. Refresh to see the latest.
View
10 runtime/lib/map/ColumnMap.php
@@ -212,6 +212,16 @@ public function isNumeric()
}
/**
+ * Whether this column is an integer
+ *
+ * @return boolean
+ */
+ public function isInteger()
+ {
+ return $this->getPdoType() === PDO::PARAM_INT;
+ }
+
+ /**
* Whether this column is a text column (varchar, char, longvarchar).
* @return boolean
*/
View
10 test/testsuite/runtime/map/ColumnMapTest.php
@@ -149,4 +149,14 @@ public function testIsPrimaryString()
$titleColumn->setPrimaryString(true);
$this->assertTrue($titleColumn->isPrimaryString(), 'isPrimaryString() returns true if set.');
}
+
+ public function testIsInteger()
+ {
+ $bookTable = BookPeer::getTableMap();
+ $idColumn = $bookTable->getColumn('id'); // INTEGER
+ $titleColumn = $bookTable->getColumn('title'); // VARCHAR
+
+ $this->assertTrue($idColumn->isInteger(), 'isInteger() returns true');
+ $this->assertFalse($titleColumn->isInteger(), 'isInteger() returns false');
+ }
}
Something went wrong with that request. Please try again.