title: Creating a single insert statement for multiple array values
body: <p><br/></p>
  
  <p>I have a query about how to implement my use case.I have a set of arrays that I want to insert in the DB,but now I am confused how can I do it efficiently.I am using <strong>PHP and MySQL</strong>.Below is the use case:<br/></p>
  
  <pre><code>$shareUrl = array();
  $theInsertUrl = array();
  $authKeyArray = array();
  </code></pre>
  
  <p>Above are the arrays I get after processing some information.Now I have to insert it into the DB,but instead of doing it one by one,I thought have a <strong>single insert</strong> would be better solution(<strong>Please correct if not</strong>).<br/>
  For multiple insert the <code>values</code> part of my SQL query must have </p>
  
  <pre><code> ($shareUrl[0],$theInsertUrl[0],$authKeyArray[0]),($shareUrl[1],$theInsertUrl[1],$authKeyArray[1]),...
  </code></pre>
  
  <p>I thought of writing a for loop and create a multidimensional array like this</p>
  
  <pre><code>  for($i=0;$i&lt;count_of_array;$i++){
          $multiArray[$i]['shareUrl'] = $shareUrl[0];
          $multiArray[$i]['theInsertUrl'] = $theInsertUrl[0];
          $multiArray[$i]['authKeyArray'] = $authKeyArray[0];
    }
  </code></pre>
  
  <p>But still it will be tedious to use this in the SQL query's <code>values</code> part as it accepts a format like this <code>('val1','val2'),('val1','val2')</code>. I need suggestions on how can I go about implementing it? Is the above approach correct or is there a better solution <strong>OR</strong> should I go it with single insert statements?</p>