SQLSTATE[42S22]: Column not found - ManyToMany relation

Hi everyone,

I'm stuck trying to create a many to many relation.

At that line

$t = poi::model()->with('pictures')->findByPk(2);

i get the following error:

CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found: 1054 Unknown column 't2.' in 'on clause'

I have a table poi which has a MANY to MANY relation to Picture, through the table poi_x_picture.

In POI I have the following relation:

'pictures' => array(self::MANY_MANY, 'Picture', 'poi_x_picture(id_poi, id_picture)')

Please, help ;)

Which version are you using? What is the SQL being executed (turn on logging to see it)?

Hi Qiang,

thank you for the help, I achieved to turn on the logging or errors and I found it out: i had no PK on the picture table.

Thanks again.