isCrossRef #415

mkehren opened this Issue Jul 13, 2012 · 3 comments


None yet

2 participants

mkehren commented Jul 13, 2012


I have problems running propel-gen with a schema which uses the isCrossRef attribute. I used the user-group example from the website:

<table name="group">
    <column name="id" type="INTEGER" primaryKey="true" autoIncrement="true"/>
    <column name="name" type="VARCHAR" size="32"/>

<table name="user_group" isCrossRef="true">
    <column name="user_id" type="INTEGER" primaryKey="true"/>
    <column name="group_id" type="INTEGER" primaryKey="true"/>
    <foreign-key foreignTable="user">
        <reference local="user_id" foreign="id"/>
    <foreign-key foreignTable="group">
        <reference local="group_id" foreign="id"/>

The propel-gen script returns this (debug)
[propel-om] Generating PHP files...
[propel-om] Datamodel: schema.xml
[propel-om] - Database: propel_test
[propel-om] + Table: user
[PHP Error] Declaration of PeerBuilder::hasBehaviorModifier() should be compatible with that of OMBuilder::hasBehaviorModifier() [line 316 of /Applications/MAMP/bin/php/php5.2.17/lib/php/data/propel_generator/lib/builder/om/PeerBuilder.php]
[PHP Error] Declaration of ObjectBuilder::hasBehaviorModifier() should be compatible with that of OMBuilder::hasBehaviorModifier() [line 214 of /Applications/MAMP/bin/php/php5.2.17/lib/php/data/propel_generator/lib/builder/om/ObjectBuilder.php]
[PHP Error] Declaration of PHP5TableMapBuilder::hasBehaviorModifier() should be compatible with that of OMBuilder::hasBehaviorModifier() [line 367 of /Applications/MAMP/bin/php/php5.2.17/lib/php/data/propel_generator/lib/builder/om/PHP5TableMapBuilder.php]
[propel-om] -> Updating propel_test/om/BaseUserPeer.php (table: user, builder: PHP5PeerBuilder)
[PHP Error] Declaration of ExtensionQueryBuilder::hasBehaviorModifier() should be compatible with that of OMBuilder::hasBehaviorModifier() [line 139 of /Applications/MAMP/bin/php/php5.2.17/lib/php/data/propel_generator/lib/builder/om/ExtensionQueryBuilder.php]

and exists.

The result is, that the generation breaks and the build/class folder only contain the BaseUserPeer.php file. When I remove the attribute isCrossRef everything works fine ... but there is of cause no m2n relation in the class files.

Is it a bug or what is the point? I am using v1.6.6.


mkehren commented Jul 14, 2012

Found it!

The problem is the function lcfirst which is only available in PHP >= 5.3.

generator/lib/builder/om/PHP5ObjectBuilder.php in line 4288:
$M2MScheduledForDeletion = lcfirst($relCol) . "ScheduledForDeletion";

I changed it to:
$M2MScheduledForDeletion = strtolower($relCol[0]) . substr($relCol, 1) . "ScheduledForDeletion";

Now the builder works fine.


@willdurand willdurand closed this in 363fce3 Aug 6, 2012

Thanks for reporting, fixed!

mkehren commented Aug 8, 2012

Looks like this problem still exists in the pear packages.

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