diff --git a/src/Symfony/Bridge/Propel1/Tests/Fixtures/ColumnMap.php b/src/Symfony/Bridge/Propel1/Tests/Fixtures/ColumnMap.php new file mode 100644 index 0000000000..5e8d972b91 --- /dev/null +++ b/src/Symfony/Bridge/Propel1/Tests/Fixtures/ColumnMap.php @@ -0,0 +1,61 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bridge\Propel1\Tests\Fixtures; + +class ColumnMap +{ + // Propel type of the column + protected $type; + + // The TableMap for this column + protected $table; + + // The name of the column + protected $columnName; + + public function __construct($name, $containingTable) + { + $this->columnName = $name; + $this->table = $containingTable; + } + + /** + * Set the Propel type of this column. + * + * @param string $type A string representing the Propel type (e.g. PropelColumnTypes::DATE). + * @return void + */ + public function setType($type) + { + $this->type = $type; + } + + /** + * Get the Propel type of this column. + * + * @return string A string representing the Propel type (e.g. PropelColumnTypes::DATE). + */ + public function getType() + { + return $this->type; + } + + /** + * Get the PDO type of this column. + * + * @return int The PDO::PARMA_* value + */ + public function getPdoType() + { + return PropelColumnTypes::getPdoType($this->type); + } +} diff --git a/src/Symfony/Bridge/Propel1/Tests/Fixtures/PropelColumnTypes.php b/src/Symfony/Bridge/Propel1/Tests/Fixtures/PropelColumnTypes.php new file mode 100644 index 0000000000..5fdef59060 --- /dev/null +++ b/src/Symfony/Bridge/Propel1/Tests/Fixtures/PropelColumnTypes.php @@ -0,0 +1,96 @@ + (Propel) + * @version $Revision$ + * @package propel.runtime.util + */ +class PropelColumnTypes +{ + + const + CHAR = "CHAR", + VARCHAR = "VARCHAR", + LONGVARCHAR = "LONGVARCHAR", + CLOB = "CLOB", + CLOB_EMU = "CLOB_EMU", + NUMERIC = "NUMERIC", + DECIMAL = "DECIMAL", + TINYINT = "TINYINT", + SMALLINT = "SMALLINT", + INTEGER = "INTEGER", + BIGINT = "BIGINT", + REAL = "REAL", + FLOAT = "FLOAT", + DOUBLE = "DOUBLE", + BINARY = "BINARY", + VARBINARY = "VARBINARY", + LONGVARBINARY = "LONGVARBINARY", + BLOB = "BLOB", + DATE = "DATE", + TIME = "TIME", + TIMESTAMP = "TIMESTAMP", + BU_DATE = "BU_DATE", + BU_TIMESTAMP = "BU_TIMESTAMP", + BOOLEAN = "BOOLEAN", + BOOLEAN_EMU = "BOOLEAN_EMU", + OBJECT = "OBJECT", + PHP_ARRAY = "ARRAY", + ENUM = "ENUM"; + + private static $propelToPdoMap = array( + self::CHAR => \PDO::PARAM_STR, + self::VARCHAR => \PDO::PARAM_STR, + self::LONGVARCHAR => \PDO::PARAM_STR, + self::CLOB => \PDO::PARAM_LOB, + self::CLOB_EMU => \PDO::PARAM_STR, + self::NUMERIC => \PDO::PARAM_STR, + self::DECIMAL => \PDO::PARAM_STR, + self::TINYINT => \PDO::PARAM_INT, + self::SMALLINT => \PDO::PARAM_INT, + self::INTEGER => \PDO::PARAM_INT, + self::BIGINT => \PDO::PARAM_STR, + self::REAL => \PDO::PARAM_STR, + self::FLOAT => \PDO::PARAM_STR, + self::DOUBLE => \PDO::PARAM_STR, + self::BINARY => \PDO::PARAM_STR, + self::VARBINARY => \PDO::PARAM_STR, + self::LONGVARBINARY => \PDO::PARAM_STR, + self::BLOB => \PDO::PARAM_LOB, + self::DATE => \PDO::PARAM_STR, + self::TIME => \PDO::PARAM_STR, + self::TIMESTAMP => \PDO::PARAM_STR, + self::BU_DATE => \PDO::PARAM_STR, + self::BU_TIMESTAMP => \PDO::PARAM_STR, + self::BOOLEAN => \PDO::PARAM_BOOL, + self::BOOLEAN_EMU => \PDO::PARAM_INT, + self::OBJECT => \PDO::PARAM_STR, + self::PHP_ARRAY => \PDO::PARAM_STR, + self::ENUM => \PDO::PARAM_INT, + ); + + /** + * Resturns the PDO type (PDO::PARAM_* constant) value for the Propel type provided. + * @param string $propelType + * @return int + */ + public static function getPdoType($propelType) + { + return self::$propelToPdoMap[$propelType]; + } + +}