inserting array into database table in single query
Posted
by Praveen Prasad
on Stack Overflow
See other posts from Stack Overflow
or by Praveen Prasad
Published on 2010-05-08T07:07:22Z
Indexed on
2010/05/08
7:18 UTC
Read the original article
Hit count: 241
iam having an array of items like
[item1,itmem2,item3];
i have to insert these items at a particular userId:
final results look like this
UserId ItemId
2 || item1
2 || item2
2 || item3
currently iam looping through the array in php code and inserting each item one by one eg
foreach($items as $item)
{
insert into items (UserId,ItemId) value (2,$item);
}
is it possible i can insert all entries in single query.
© Stack Overflow or respective owner