I have the following custom builder (I need to supply a builder instnace to a package that I use)
public function query()
{
$connection = $this->getConnection();
return $connection->table(
$connection->raw('(' . $this->mainQuery()->toSql() . ') abc')
)->select('*');
}
public function mainQuery()
{
$q1 = $this->firstQuery();
$q2 = $this->secondQuery();
return $q1->unionAll($q2);
}
private function firstQuery()
{
return $this->topic
->where('title', 'LIKE', '%'.'test'.'%')
->select(['message', 'created_at']);
}
private function secondQuery()
{
return $this->reply
->where('message', 'LIKE', '%'.'test'.'%')
->select(['message', 'created_at']);
}
Doing a
$builder = app(QueryBuilderHelper::class);
$query = $builder->query();
return $this->applyScopes($query);
results in
General error: 2031 (SQL: select count(*) as aggregate from (select * from ((select `message`, `created_at` from `topics` where `title` LIKE ? and `topics`.`deleted_at` is null) union all (select `message`, `created_at` from `replies` where `message` LIKE ? and `replies`.`deleted_at` is null)) abc) count_row_table)"}
I don't see what the issue is..
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire