I have been using the following query to upload my data into mysql database:
$sql = array();
foreach( $data as $row ) {
$sql[] = '("'.mysql_real_escape_string($row['text']).'", '.$row['category_id'].')';
}
mysql_query('INSERT INTO table (text, category) VALUES '.implode(',', $sql));
Since a bit I have started using PDO and my query looks like this:
$query="INSERT INTO mytable (name, use) VALUES(:sname, :usee)";
$res = $db_conn->prepare($query);
$res->bindValue(':sname',$value);
$res->bindValue(':usee',$_SESSION['usee']);
$res->execute();
Now the above code block is fine, but now when I am going through my CSV upload thing, I again looking backward and using the first code. Want to use the same PDO now for CSV upload also.
Is there a trick to upload multiple values in database using PDO at once?