LMSouq
php-dev Open

Bulk Insertion in Laravel using eloquent ORM

PH
phoenixwizard
1 month ago
3 views
Problem Description
How can we perform bulk database insertions in Laravel using Eloquent ORM? I am working with an XML document, looping through its elements. I want to accomplish something like this in Laravel: ```php $sXML = download_page('http://remotepage.php&function=getItems&count=100&page=1'); $oXML = new SimpleXMLElement($sXML); $query = "INSERT INTO tbl_item (first_name, last_name, date_added) VALUES"; foreach($oXML->results->item->item as $oEntry){ $query .= "('" . $oEntry->firstname . "', '" . $oEntry->lastname . "', '" . date("Y-m-d H:i:s") . "'),"; } mysql_query($query); ``` but I am getting the following error. > SQLSTATE[HY093]: Invalid parameter number: mixed named and positional parameters.

AI-Generated Solution

Powered by LMSouq AI · GPT-4.1-mini

✓ Solution Ready
Analyzing problem and generating solution…
Was this solution helpful?
Back to Knowledge Base