This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

leocavalcante
leocavalcante

I'm joining a table at the controller method extendListQuery, but also at a model scope. So I'm getting the SQL error: 1066 Not unique table/alias Any one already faced that problem? How to solve?

leocavalcante
leocavalcante

Well, Not proud of this jerry-rig, but works:

At scope, I put something like: $query->isJoining = true

Then, at extendListQuery: if (!isset($query->isJoining)) { /*The same join*/ }

Scott
Scott

Just alias your joined table

$query->join('joined_table as aliased_table', 'foo', '=', 'bar');

Further, if you're joining a subquery you'll want to do that at the very beginning of your query. https://github.com/scottbedard/oc-shop-plugin/blob/master/controllers/Products.php#L35-L64

Last updated

leocavalcante
leocavalcante

Wow listExtendQueryBefore, that is exactly what I need. thanks man.

Why is this undocumented?!!

Cheers!

1-4 of 4

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.