Skip to content
This repository

BIGINT Issue. #459

Closed
tkess opened this Issue · 4 comments

3 participants

tkess Francois Zaninotto William Durand
tkess

Not sure if this is intentional by propel...but I am having issues with queries and bigints with mysql/php--namely query returns empty set even though its a valid query. When I look at PropelTypes.php it contains the following--which seems to convert the BIGINT into a PDO::PARAM_INT not a PDO::PARAM_STR. Should the line read: self::BIGINT => PDO::PARAM_STR instead of self::BIGINT => PDO::PARAM_INT,

 /**
     * Mapping between Propel types and PDO type contants (for prepared statement setting).
     *
     * @var        array
     */
    private static $propelTypeToPDOTypeMap = array(
            self::CHAR => PDO::PARAM_STR,
            self::VARCHAR => PDO::PARAM_STR,
            self::LONGVARCHAR => PDO::PARAM_STR,
            self::CLOB => PDO::PARAM_STR,
            self::CLOB_EMU => PDO::PARAM_STR,
            self::NUMERIC => PDO::PARAM_INT,
            self::DECIMAL => PDO::PARAM_STR,
            self::TINYINT => PDO::PARAM_INT,
            self::SMALLINT => PDO::PARAM_INT,
            self::INTEGER => PDO::PARAM_INT,
            self::BIGINT => PDO::PARAM_INT,
            self::REAL => PDO::PARAM_STR,
            self::FLOAT => PDO::PARAM_STR,
            self::DOUBLE => PDO::PARAM_STR,
            self::BINARY => PDO::PARAM_STR,
            self::VARBINARY => PDO::PARAM_LOB,
            self::LONGVARBINARY => PDO::PARAM_LOB,
            self::BLOB => PDO::PARAM_LOB,
            self::DATE => PDO::PARAM_STR,
            self::TIME => PDO::PARAM_STR,
            self::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,

            // These are pre-epoch dates, which we need to map to String type
            // since they cannot be properly handled using strtotime() -- or even numeric
            // timestamps on Windows.
            self::BU_DATE => PDO::PARAM_STR,
            self::BU_TIMESTAMP => PDO::PARAM_STR,
    );
Francois Zaninotto
Collaborator

There is an incoherence between the generator binding types (the one you mention, https://github.com/propelorm/Propel/blob/master/generator/lib/model/PropelTypes.php#L191) and the runtime binding type (https://github.com/propelorm/Propel/blob/master/runtime/lib/util/PropelColumnTypes.php#L64). The latter is correct, and Doctrine DBAL also uses PDO::PARAM_STR as well for BIGINTs (http://www.doctrine-project.org/api/dbal/2.1/source-class-Doctrine.DBAL.Types.BigIntType.html#26). So I think this should be fixed.

Out of curiosity, why do you need to do binding at buildime? For fixtures?

tkess

Thanks for the response. I was really just trying to read from the database with a specific query--not loading fixtures. The query string would be correctly formed--but of course it would not get a result back from the PDO as PHP was truncating the id string (which was the BIGINT).

Francois Zaninotto
Collaborator

I still don't understand in which context you would use the propel commands to do that, rather than using the PHP model.

tkess
Toni Uebernickel havvg referenced this issue from a commit in Ormigo/Propel
Toni Uebernickel havvg Merge branch 'master' into ormigo
* master:
  Fixes #345
  Allow the QuickGenerator to use another Platform
  Change fallback order in getTableByPhpName(). Fixes #385
  Fix initialization of internal iterator for getRelCol. fix #460
  Add a test for initialization of internal iterator for related object collection getter fix #460
  Fix PR #544
  teaching propel to clear UP and DOWN when calling clearAllReferences(true) we have infinite recursion prevention already covered also we add an optional param to clearInstancePool. if passes as true it will clearAllReferences(true) on every instance before clearing it.
  Fix CS
  Fix cast in setters. Should fix #283
  Fix inconsistency for BIGINT. Fixes #459
  Use model prefix in QueryInheritanceBuilder, fixes #542
  fix variable name on boolean filter methods
  Tests for improved ENUM handling
  Improved getValueSet() method, added ENUM getters for SQL value, set Query filter to use SQL getters
  Add PHP 5.5 to travis config
  Update generator/lib/builder/om/PHP5PeerBuilder.php
  sqlType="enum(..)" now set the valueSet attribute it is not required to use Propel::ENUM as type
7d94f67
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.