title: Posting child objects to a database with php
body: <p>I am trying to post child objects to a database with php and can't figure this out, any help is appreciated.  The top clientId to invAmount posts fine, but the invoiceDetails child objects is where I am getting confused, I tried a while loop but no luck, I am a ui guy not php so I'm out of ideas.</p>
  
  <p>The post:</p>
  
  <pre><code>{
  "clientId": "5",
  "invNumber": "2",
  "invProject": "Test Project",
  "invDescription": "Test",
  "invDate": "09/20/2013",
  "invAmount": "5000",
  "invoiceDetails": [
      {
          "invRowDescription": "Description 1",
          "invRowHours": "50",
          "invRowRate": "50",
          "invRowTotal": 2500
      },
      {
          "invRowDescription": "Description 2",
          "invRowHours": "50",
          "invRowRate": "50",
          "invRowTotal": 2500
      }
  ]
  }
  </code></pre>
  
  <p>The php controller</p>
  
  <pre><code>&lt;?php
  $_POST = json_decode(file_get_contents('php://input'), true);
  
  
  // Independent configuration
  require 'medoo.php';
  $database = new medoo(array( 
   // required 
    'database_type' =&gt; 'mysql', 
   'database_name' =&gt; 'dbname', 
   'server' =&gt; 'server', 
   'username' =&gt; 'user', 
   'password' =&gt; 'pw' 
  
  ));
  
  $database-&gt;insert("invoiceSummary", array(
       "clientId" =&gt; $_POST['clientId'],
       "number" =&gt; $_POST['invNumber'],
      "project" =&gt; $_POST['invProject'],
      "description" =&gt; $_POST['invDescription'],
       "date" =&gt; $_POST['invDate'],
       "amount" =&gt; $_POST['invAmount']
  ));
  
  while($rowInv = mysqli_fetch_array($_POST['invoiceDetails'])) {
      $database-&gt;insert("invoiceDetails", array(
         "clientId" =&gt; $_POST['clientId'],
  "number" =&gt; $_POST['invNumber'],
      "description" =&gt; $_POST['invRowDescription'],
      "hours" =&gt; $_POST['invRowHours'],
      "rate" =&gt; $_POST['invRowRate'],
      "total" =&gt; $_POST['invRowTotal'],
  ));
  }
  
     echo json_encode('success');
     ?&gt;
  </code></pre>