Closed ParthWeb closed 3 years ago
I also want to know
This is not supported yet, but probably should be.
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.
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])
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.
This change requires some documentation updates... Anyone want to volunteer?
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