-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create a calculated field in a query #36
Comments
Mmm, it is not possible for now. selectAggregate expects an existing field of the table, not a math operation. $db->product->selectAggregate('SUM', 'qty*sale_price', 'total_stock')->get(); I can work in this feature in one or two weeks. But you feel strong and want to contribute with a PR, you're welcome. |
That already did the job! Thanks It's a nice code. I'm using it actually as an alternative to REST APIs with small projects. It started when I didn't found a compiled version of last MariaDB server for ARM distros (Raspberry Pi)... So no Stored Aggregate Functions, no JSON functions... This one for example was made for a friend for an inventory project.. Live Linking Memento Database app to a LAN mysql server. So he could scan products' barcodes and instantly (Insert/Update) products Thanks again and sure if something comes to my mind, Ill pull a request. |
Hi. I just made a commit with this change. Could you test it before tag a new release? |
It's working Perfect & Clystar clear! And really Thanks for keeping the same syntax. It would be easier to perform inline calculations this way and that's similar to the usual MySql syntax. |
Great! New version released. |
Hi,
Is it possible to add Mathematic operations to Queries using this project?
For example, a product of "stock" and "price" and performing that multiplication inside a SUM
We can do this:
$db->product->selectAggregate('SUM', 'price')->get();
which is like : SELECT SUM('price') AS ...
But How to do this? :
SELECT sum(qty*sale_price) as total_stock
The text was updated successfully, but these errors were encountered: