FaaPz / PDO

Just another PDO database library
MIT License
316 stars 103 forks source link

Can we use multiple insert statement in FaaPz / PDO #104

Closed ParthWeb closed 3 years ago

ParthWeb commented 6 years ago

INSERT INTO employee(eid, ename, email, ebirthdate) VALUES (null,'test','test1@*.com',1530101800), (null,'test','test@.com',1530101800)

Can we create statement in slim pdo for multiple insert in one single query

lkp186 commented 5 years ago

I also want to know

kwhat commented 5 years ago

This is not supported yet, but probably should be.

kwhat commented 5 years ago

I am thinking about how to implement this and would like to get some feedback from you. I am thinking about modifying the Insert::values(...) method to append to a values array instead of replacing it. The usage would be something like $pdo->insert("table")->columns("col1", "col2")->values(1, 2)->values(3, 4);. The only drawback to this approach is that the values would be immutable. Basically, if you added values to the insert object, you cannot remove those values.

Caffe1neAdd1ct commented 5 years ago

Might be useful to accept an iterator or array of arrays [[1,2], [3,4]] however this could be left to the end developer to loop on the $pdo instance calling ->values([1,2])

kwhat commented 4 years ago

I have decided to support the multi-dimensional array approach as it is more inline with similar method usage and it is backward compatible. I will be pushing changes to the 2.1 branch tonight. I will tag this issue in vcs.

kwhat commented 4 years ago

This change requires some documentation updates... Anyone want to volunteer?