Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Insert multiple rows with one db-action
Is ist possible to insert multiple rows with one action.
For example. I habe a table "tags" and want to save a few tag.
now I am doing it so:
$tag_array = array('tag1', 'tag2');
foreach($tag_array as $tag)
(Pseudocode: code type here for demonstarated)
No, not via ORM.
An ORM is an object relational mapper, which maps individual records to objects (and the other way around). An ORM is not a query builder that you can use to generate arbitrary queries, you need to use the query builder (DB) for that.
DB::insert() supports multiple inserts at once if you use the values() method instead of set(), and you pass an array of rows to it.
Add a Comment
It looks like you're new here. If you want to get involved, click one of these buttons!
Apply for Membership
↳ Job Board
↳ Installation & Setup
↳ Tips and Tutorials
↳ Code share
In this Discussion