title: How to save to data into database which is in array format
body: <p>I have this following array. I want to insert data into two tables on single save link. How can I do this?</p>
  
  <p>First three fields will save in products table and the <code>opt_vals</code>, which is an array, will be saved in another table called as <code>product_links</code>.</p>
  
  <p>Also I want to insert <code>lastInsertId</code> into <code>product_links</code> table. <code>product_links</code> fields as <code>id</code>, <code>product_id</code>, <code>product_values</code>.</p>
  
  <pre><code>Array
  (
      [Product] =&gt; Array
      (
          [product_name] =&gt; 
          [product_desc] =&gt; 
          [price] =&gt; 
          [opt_vals] =&gt; Array
              (
                  [0] =&gt; Array
                      (
                          [id] =&gt; 
                      )
  
                  [1] =&gt; Array
                      (
                          [id] =&gt; 
                      )
  
                  [2] =&gt; Array
                      (
                          [id] =&gt; 
                      )
  
                  [3] =&gt; Array
                      (
                          [id] =&gt; 
                      )
  
                  [4] =&gt; Array
                      (
                          [id] =&gt; 
                      )
  
                  [5] =&gt; Array
                      (
                          [id] =&gt; 
                      )
  
                  [6] =&gt; Array
                      (
                          [id] =&gt; 
                      )
  
                  [7] =&gt; Array
                      (
                          [id] =&gt; 
                      )
             )
      )
  )
  </code></pre>