I have a Product Entity with many Orders as association. I want to build a repository method that brings the most sold products. Each order only have 1 product with 1 quantity so, quantity is …
Tag: mysql
Can some SQL queries be executed while the others fail?
I have read from some posts that it is a better practice to execute queries one by one instead of doing the multi-query function in PHP files. I wonder say I have two mysqli_query functions, is it possible that the first query succeeds and MySQL Database has been changed accordingly when the next query fails?…
Update price column in database laravel
I am trying to pass along updated pricing to my orders table but am getting an error: In my controller I have this: The error is coming from the $newPaymentTotal that I want use to update the price that was in there before. That column is set up as a decimal as well. Answer Your line $request->session()-&g…
Maching users from username to user_group
So im setting up a ranks system on my website. (there is probably an easier way to do it) Here is what i tried. and here is my server.php file for extra info. (details included) Basically i want to set certain sessions to certain groups, its the only way i can hide links from users that are either logged in/l…
PHP does not output isset array from Mysql. Although through print_r the array is displayed
The Mysql command is set correctly, since the data is displayed correctly via print_r($ads). I pack the resulting array into $ads Catch id Query DB. But through the isset function, they are not shown, no errors are displayed, nothing, just a blank page. I output the data like this short_tags are included in P…
Remove space or replace with underscore of auto generated ID tags
Completely revising my question. I am using this code to generate an id tag: Which produces this html: I cant have a space in the id. I need to either remove it on replace it with an underscore. Is there a way to accomplish this? This did not work: Thanks to Nico Bleiler for pointing out my original code erro…
Force doctrine datatype choice, from tinytext to varchar
I’ve describe my entity with short text properties with fixed length. When I use the command make:migration, it generates an SQL code with TINYTEXT datatype. In my case it will be more accurate to use VARCHAR, as my properties have short fixed length. I’ve search, but I find no satisfying solution…
Can I call a stored procedure on each iteration of an array? PHP
I want to loop through an associative array that represents a table’s columns and values, and call a stored procedure on each iteration that will insert each value into its respective column. The assoc. array and loop looks like this: The stored procedure looks like this: Is this possible to do? Or is t…
mysqli query inside foreach loop- syntax problem
I have the following mysqli query: This is my database table “items”: $response is an API array from where I get the value for the item_ids . I get the following error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use …
Mysql statement where not exists with time intervals
I am basically trying to get my app to report when items are not returned or overdue in a 5 day and 15 day window. After much trial and error the below coded is the best I could come up with. However, …