0
I’m performing a query in my base with some LEFT JOIN and some WHERE clauses, however, I’m having a lot of difficulties with the return of this query that, for having many results, simply after a certain processing time gives error 500. For example:
- I did the query and ran it returning only 1 result - it worked;
- I made the query returning a short time (5 days only) with about 9 thousand records - It worked;
- I made the query with 15 days, return approximately 30 thousand records - Does not work, gives error 500.
- I made the consultation with 14 days, returned about 28 thousand records - It worked O.o
In this case, there is the need, on the part of the client to return data up to 60 days and the way it is, does not work.
Follow the query:
$this->clientes->select('clientes.id', 'clientes.nome', 'clientes.email', 'clientes.created_at',
'clientes.updated_at AS ultima_atualizacao', 'origem.titulo AS titulo_origem',
'clientes.sexo', 'produtos.nome AS nome_produto', 'clientes.tipo_logradouro',
'clientes.telefone1', 'clientes.telefone2', 'clientes.telefone3',
'clientes.logradouro', 'clientes.numero', 'clientes.complemento', 'clientes.bairro',
'clientes.cidade', 'clientes.estado', 'clientes.cep', 'clientes.status',
'usuarios.susep_principal',
'produto_auto_veiculo.marca', 'produto_auto_veiculo.modelo', 'produto_auto_veiculo.ano_fabricacao',
'produto_auto_veiculo.ano_modelo', 'atendimento_cliente.hora_vinculo',
'atendimento_cliente.created_at AS ultimo_contato')
->leftJoin('atendimento_cliente', 'clientes.id', '=', 'atendimento_cliente.id_cliente')
->leftJoin('produtos', 'produtos.id', '=', 'atendimento_cliente.id_produto')
->leftJoin('origem', 'origem.id', '=', 'clientes.id_origem')
->leftJoin('usuarios', 'usuarios.id', '=', 'clientes.id_corretor')
->leftJoin('pedidos', 'usuarios.id', '=', 'pedidos.id_cliente')
->leftJoin('produto_auto_veiculo', 'produto_auto_veiculo.pedido_id', '=', 'pedidos.id')
->orderBy('clientes.' . $inputs['ordem'], 'desc')
->groupBy('clientes.id')
->get()
Where is the
Where
?– Diego Souza
There is a method that Implements the
WHERE
if is requested. Look an example:->where('estado', $this->inputs['name_search']);
, but it isn’t obligatory on query, just is called if a request is Filtered. In this example, I have the same problem, if I Return one data withfirst()
of eloquent, it Works, but if I Return withget()
Give 500 error.– Ewerton Melo
I speak Portuguese, I just made a joke using the
where
. There is nothing wrong when you choose 15 days to make the query ? Your fileconfig.php
in the briefcaseapp
is withdebug => true
?– Diego Souza
What is the specific error? error 500 is Generico does not say what is the root of the problem.
– rray
Probably memory exhaustion. For these things not to occur, I always use paging. If applicable, implement Infinite scroll in your application.
– Wallace Maxters
Two problems, the first is that it simply does not present the error itself, only error 500. Debug enabled, native error screen rendering Ok, made tests on other pages simulating error 500 working, but only in this case returns nothing. I checked Laravel’s log, and I also got no response to the error. Regarding pagination, I cannot use, this data is necessary to generate a CSV. ;(
– Ewerton Melo
You must separate the answer part of the question, after a few minutes accepted the answer(green light), means that the problem has been solved.
– rray