I have a server that keeps running out of memory, and I'm trying to pinpoint the issue. It's a pretty large database made up of a product catalog being queried, and one thing I read was that storing the results of a database query in a variable was generally the culprit, and using -> or => vs just the variable was one best practice but I haven't found a good example explaining the benefits or its usage.
For arguments sake, let's say I have a basic query like this:
$sql= ("SELECT variable1, variable2, variable3 FROM table1");
while ($row = mysql_fetch_array($sql)) {
$variable1 = ($row ['variable1']);
$variable2 = ($row ['variable2']);
$variable3 = ($row ['variable3']);
}
Is there a better way to write this for the sake of not taking up as much memory? Thanks in advance, I appreciate it.