Field::inst with subquery return null in mysql
Field::inst with subquery return null in mysql
Greetings,
I'm using a subquery in the Field::inst() of PHP editor class.
For example, the main table is Sales
:
Field::inst('(SELECT SUM(payments.price) FROM `payments` WHERE payments.sale_id = sales.id)','net_price')
This query works fine in Sqlite, I also copied the query from (debug) and run it in phpmyadmin, and worked fine. It is returning (3000) for example.
But the returned value is null in the JSON. I tried to put getFormatter and var_dump the $data variable. It is also Null.
Btw sorting works fine for the real net_price value of the record behind the seen, although it still appears as null.
Am I missing something ? or there is kind of protection between the Mysql result and formatting the value in response ?
Answers
Can you add
->debug(true)
just before the->process(...)
call please? Then show me the JSON being returned from the PHP when you initially load the page (from your browser's "Network" inspector).Thanks,
Allan