Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Insert array of data to database
  • Dear,

    Suppose, I have a array of data, contain 100s of rows, and some columns, I would like to add whole array to database, How it is possible? Shall i need each query for each row? or any easy way with single query? each Row represent each entry and array column represent each fields in table.
  • You can pass a multi-dimensional array to DB::insert()->values(), containing multiple rows. It will generate a multi-row INSERT from that.
  • HarroHarro
    Accepted Answer
    No, ORM is object based, and an object always is one record.

    And as an object is not aware of other existing objects, ORM will never generate a multi-row insert.

    Since you didn't ask this in ORM but in General, I assumed it was a DB question.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion