Jump to content

Variable variable within mysql query?


morocco-iceberg

Recommended Posts

You do realize that if you used an array, the syntax would be easier to figure out and it would be quicker -

 

If $q is an array so that the values are $q[0], $q[1], $q[2], you would use '{$q[$counter]}' to reference them in the query.

Link to comment
Share on other sites

Not to mention that setting or referencing an array variable is 3x faster than using a variable-variable. Also with arrays, you can use array functions, such as foreach() and count() so that you don't need to keep track of how many of or what the names of the variable-variables are.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.