Closed maxi032 closed 1 year ago
I am trying to join table entries with itself based on a few criterias. This is the query:
$query = EntryFacade::query()->leftJoin('entries as eTags', fn ($join) => $join ->whereColumn('eTags.id', 'entries.origin_id') )->select('entries.*','eTags.data as origin_data') ->where('entries.collection', 'news') ->where('entries.published', true) ->where('entries.origin_id', null) ->where('entries.site', $locale) ->limit($limit)->offset($offset); $entries = $query->get();
I get 10 items as I have $limit set to 10 but the problem is that all the properties of those items are null.
If I run the query in a mysql client, I get the expected result.
This is the query:
"query" => "select * from `entries` left join `entries` as `eTags` on `eTags`.`id` = `entries`.`origin_id` where `entries`.`collection` = ? and `entries`.`published` = ? and `entries`.`origin_id` is null and `entries`.`site` = ? limit 10 offset 0 ◀" "bindings" => array:3 [▼ 0 => "news" 1 => true 2 => "en" ] "time" => 1.15
I am using:
Environment
Cache
Drivers
Statamic
Statamic Addons
Are you trying to get the origin data for any entry? If so this PR should resolve that: https://github.com/statamic/eloquent-driver/pull/114
I am trying to join table entries with itself based on a few criterias. This is the query:
If I run the query in a mysql client, I get the expected result.
This is the query:
Environment
Cache
Drivers
Statamic
Statamic Addons