1

which one of the following is the proper way to perform multiple queries? These queries are on the same table (but they need to be different because of SUM function on different conditions)

$var1=($db->query($query1))->fetch(); $var2=($db->query($query2))->fetch(); $var3=($db->query($query3))->fetch(); $temp=$db->query($query1); $var1 =$temp->fetch(); $temp=$db->query($query2); $var2 =$temp->fetch(); $temp=$db->query($query3); $var3 =$temp->fetch(); $vars1=$db->query($query1); $var1 =$vars1->fetch(); $vars2=$db->query($query2); $var2 =$vars2->fetch(); $vars3=$db->query($query3); $var3 =$vars3->fetch(); 

If they are the same, as I suppose, can it happen that only the third works with some specific PHP configuration?

Thank you in advance

Davide

2
  • the ones that work are proper, the ones that dont work are not Commented Mar 3, 2016 at 0:04
  • Aren't the second and third one the same? You are just using a differently-named variable for the pdo statement object. Commented Mar 3, 2016 at 0:27

1 Answer 1

1

which one of the following is the proper way to perform multiple queries?

In theory they range from best to worst in terms of memory consumption, but for your particular query returning just one number, it's practically all the same.

it happen that only the third works with some specific PHP configuration?

No.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.