Symfony2 + Propel Collection undefined offset: 2 Symfony2 + Propel Collection undefined offset: 2 symfony symfony

Symfony2 + Propel Collection undefined offset: 2


Your schema is a little confusing to me. This bit below includes three primary keys with two of them as a foreign key and one of them as a unique identifier for the row:

<table name="labels_labels_lines_maps" isCrossRef="true">    <column name="id"            type="integer"            required="true"            autoIncrement="true"            primaryKey="true"/>    <column name="label_id"            type="integer"            primaryKey="true"/>    <column name="label_lines_id"            type="integer"            primaryKey="true"/>    <foreign-key foreignTable="labels" onDelete="cascade">        <reference local="label_id" foreign="id"/>    </foreign-key>    <foreign-key foreignTable="labels_lines" onDelete="cascade">        <reference local="label_lines_id" foreign="id"/>    </foreign-key>    <vendor type="mysql">        <parameter name="Engine" value="InnoDB" />        <parameter name="Charset" value="utf8" />    </vendor></table>

I suspect a lot of your trouble may go away if you pick one thing and stick with it. Either remove id and have your primary composite key represent two foreign tables, which is perfectly valid, or change your PRIMARY KEYs to UNIQUE constraints on each of your foreign keys, leaving your primary key as id. This is also perfectly valid. Ultimately your decision will be based on your design requirements.

Another note: You may or may not want to do a heavyIndexing, particularly if you're referencing individual columns in the primary key. A composite primary key creates an index against all three columns, not each individually. That may or may not be important in your project but I thought it would be worth pointing out.


I'm not 100% sure on this, but I'm fairly certain it is because this line:

$labels = LabelsQuery::create()->findPk($id);

You'll notice in the method findPkSimple in your BaseQuery class it is expecting that the variable key be an array with 3 values (indices 0, 1, 2)

The reason why I'm unsure is I don't know if $id is just one value or an array as the function definition you have doesn't restrict on type. (your editAction function)

I think, because you have three primary keys, the class that gets generated expects you to have three individual values when searching by primary key.

It might be more effective if you only have one primary key, and then an unique index on those three columns to ensure uniqueness (if that's what you're going for)