Phalcon 4, problem with relations

I have some raltions in model

$this->hasManyToMany("id", "ProductMedia", "product_id", "media_id", "Media", "id", [ "alias" => 'media' ]);

$this->hasManyToMany("id", "ProductEvents", "product_id", "event_id", "Event", "id", [ "alias" => "events" ]);

When I try to get $product->media - its ok, but when I get $product->events I got an error

Scanning error before '].id DESC LIMIT ...' when parsing: SELECT [Event].* FROM [Event] INNER JOIN [ProductEvents] ON [ProductEvents].[event_id] = [Event].[id] WHERE [ProductEvents].[product_id] = :APR0: ORDER BY [].id DESC LIMIT :APL0:

Where could the problem be?

Check the table definitions. It appears that ProductEvents isn't set up the same way as ProductMedia



135
edited 9d ago

Scanning error before '].id DESC LIMIT ...' when parsing: SELECT [Image].* FROM [Image] INNER JOIN [ProductImages] ON [ProductImages].[image_id] = [Image].[id] WHERE [ProductImages].[product_id] = :APR0: ORDER BY [].id DESC LIMIT :APL0:

Scanning error before '].id DESC LIMIT ...' when parsing: SELECT [Role].* FROM [Role] INNER JOIN [RoleAccount] ON [RoleAccount].[role_id] = [Role].[id] WHERE [RoleAccount].[account_id] = :APR0: ORDER BY [].id DESC LIMIT :APL0:

I was wrong, problem with all relations Many-to-Many



6.5k

double check the models' class name

and would help if you include the db schema



103

problem looks hard