Using Laravel 6, and so Eloquent Collection classes. So I have a “lot” of data to process. Roughly 5000 rows, and when fetching it, this generates a Collection of 5000 models. Now each of those models has maybe 20 attributes that need to be read. Is there a fast way to do this? I currently have an…
Tag: php
PHPMailer sends the same email twice
I am using PHPMailer to send emails from a PHP file. Here you have all the code for it: And here is how am I calling the php_mailer function: My issue is that PHPMailer is sending every email twice. Answer I suspect your browser is sending repeated requests due to a plugin. This is not an unusual problem; the…
How to force either single or double quotes in PhpStorm?
In a PHP codebase, there is a code style of always using single quotes over double quotes. How do I configure PhpStorm to always use either single or double quotes depending on the project’s preference? I don’t want to think about typing ‘ or “, PhpStorm should transform it for me auto…
Laravel eloquent update column using relationship column
How can achieve this query? Sale::with([‘catalog’]) ->whereIn(‘id’, $ids) ->update([‘price’ => DB::raw(‘catalog.price’)]); This is not working, it shows undefined table… I tried to …
Select values based on database result
I have a form with a multi select which presents the user with a list of groups to chose from,which is then saved in the database. My aim is that when the user wants to edit his information, the …
$_POST request works with postman but not in android app
I’ve been on this problem for a while now currently trying to convert my php scripts to PDO but the $_POST are always giving me null when ran through isset(). My code in android works fine with my other scripts but this one only works in postman when I change the $_POST to $_REQUEST on each item and the…
How can I prevent Symfony trying to load a service while using Swift Mailer Attachment?
I try to attach a file via Swiftmail to my Email in Symfony: $message = (new Swift_Message($message)) ->setFrom([$smtpMail => $smtpName]) ->setTo($smtpMail) ->setBody($…
Adjusting values in MySQL based on current value
My database is for keeping track of user’s balances, and there are certain actions that will add or remove balance from the users. Currently I am doing this to get the balance and update it $conn->…
PHP: mysqli_stmt->close() affecting earlier copy of stmt
I am making a function to more easily use prepared statements in sql queries. But while working on it, I ran into a strange bug. When you run the code below the first var_dump of $response prints the $…
PHP loop to output image gallery in Bootstrap with four thumbnails per row
Ok so I’ve been trying to find a definitive answer to this question and have not found one – so please do not mark this as a duplicate because none of the answers on here have worked for me. I have a …