0
votes

I try to do a query on a view from DB, with Laravel but I get an error, and I am not sure why.

ViewData::query()->where('page', '=', '918');

"SQLSTATE[42601]: Syntax error: 7 ERROR: zero-length delimited identifier at or near """"↵LINE 1: ...data" where "page" = $1 order by "view_full_data"."" asc lim...↵
^ (SQL: select * from "view_full_data" where "page" = 918 order by "view_full_data"."" asc limit 1000 offset 0)"

From Postgres, a working one.

Select * from view_full_data where "page = 918;
1
Can you see the stacktrace and find the line in your code that fails, i do not believe the line showing is the one - mrhn
I try to do the same thing with another Model, where I have "page" , and works. Also this is used in Maatwebsite\Excel . If I try it without where on my view works. - Beusebiu

1 Answers

1
votes

I found the problem.

From Maatwebsite\Excel I get an order_by that is not ok (Maybe because I don't have an ID column).

I had to add orderBy manually.

ViewData::query()->where("page", '=', "918")->orderBy('page', 'asc');