Closed phpLHT closed 5 years ago
i have solved by get the database prefix namespace TeamTNT\Scout\Engines;
The search index results ($results['ids']) need to be compared against our query
all the valid results. */ private function discardIdsFromResultSetByConstraints($builder, $searchResults) { $qualifiedKeyName = $builder->model->getQualifiedKeyName(); // tableName.id $subQualifiedKeyName = 'sub.' . $builder->model->getKeyName(); // sub.id
$database=config('database.connections'); //databaseInfo $useDatabase=config('database.default'); //default $prefix=isset($database[$useDatabase]['prefix'])?$database[$useDatabase]['prefix']:''; //prefix
$sub = $this->getBuilder($builder->model)->whereIn( $qualifiedKeyName, $searchResults ); // sub query for left join
$discardIds = $builder->model->newQuery() ->select($qualifiedKeyName) ->leftJoin(DB::raw('(' . $sub->getQuery()->toSql() .') as '.$prefix.'sub'), $subQualifiedKeyName, '=', $qualifiedKeyName) ->addBinding($sub->getQuery()->getBindings(), 'join') ->whereIn($qualifiedKeyName, $searchResults) // ->whereNull($subQualifiedKeyName) //we i use this get null ->pluck($builder->model->getKeyName());
// returns values of $results['ids'] that are not part of $discardIds return collect($searchResults)->diff($discardIds); }
when I use Support::search($request)->get(); is ok but when I use Support::search($request)->paginate(10);
an issue occour;
lluminate \ Database \ QueryException (42S22) SQLSTATE[42S22]: Column not found: 1054 Unknown column 'eisoo_sub.id' in 'where clause' (SQL: select
eisoo_support
.id
fromeisoo_support
left join (select * fromeisoo_support
where 0 = 1) as sub oneisoo_sub
.id
=eisoo_support
.id
where 0 = 1 andeisoo_sub
.id
is null) Previous exceptions SQLSTATE[42S22]: Column not found: 1054 Unknown column 'eisoo_sub.id' in 'where clause' (42S22) SQLSTATE[42S22]: Column not found: 1054 Unknown column 'eisoo_sub.id' in 'where clause' (42S22)laravel 5.5 "teamtnt/laravel-scout-tntsearch-driver": "3.3.0"