Inserting an array into database
<p>Does anyone have best practices when inserting an array into a database? I've used foreach loops with success in the past, as well as various array functions. Is there a better way? </p>

<p>Here is a sample code:</p>

<pre><code>public function InsertRequests($id) {

$db = Database::getHandler();

$selected_requests = $this-&gt;GetRequests($this-&gt;allrequests);

  foreach($selected_requests as $requestid) {

$sql = "INSERT INTO requests (userid,requestid,date) VALUES (?,?,NOW())"; 
        $stmt = $db-&gt;prepare($sql);
        $stmt-&gt;bindParam(1,$id,PDO::PARAM_STR);
        $stmt-&gt;bindParam(2,$requestid,PDO::PARAM_STR);
        $stmt-&gt;execute();

    }

    return true;
}
</code></pre>

<p>}</p>
