$arr = Array ([0] = = Array ([u_id] = 1 [UserID] = feng003 [status] = 3 [Confirm_time] = 1427940803 [Pv_total] = 0.00) [1] = = Array ( [U_ID] = 1 [UserID] = feng003 [Status] = 3 [Confirm_time] + 142 8477888 [Pv_total] = 0.00) [2] = = Array ([u_id] = 1 [userid ] = feng003 [Status] = 3 [Confirm_time] = 1428475892 [Pv_total] + 0.00 ) [3] = = Array ([u_id] = 2 [UserID] = feng001 [status] = 3 [Confirm_time] = 1428482901 [Pv_total] = 0.00) [4] = = Array ( [U_ID] = 2 [UserID] = feng001 [Status] = 3 [confirm_time] + 1428483116 [Pv_total] => 0.00) [5] = = Array ([u_id] = 1 [UserID] = feng003 [sta TUS] = 3 [Confirm_time] = 1428483542 [Pv_total] = 20.00) [6] = = Array ([u_id] = 1 [UserID] = feng003 [Status] = 3 [Confirm_time] =&G T 1428475881 [Pv_total] = 40.00) [7] = = Array ([u_id] = 5 [US Erid] = feng005 [Status] = 3 [Confirm_time] = 1428474458 [pv_total] + 100 . xx) [8] = = Array ([u_id] = 4 [UserID] = feng004 [status] = > 3 [Confirm_time] = 1428475275 [Pv_total] = 100.00) [9] = = Array ( [U_ID] = 3 [UserID] = feng002 [Status] = 3 [confirm_time] + 14 28475478 [Pv_total] = 100.00) [Ten] = = Array ([u_id] = 2 [UserID] = feng001 [Status] = 3 [Confirm_time] = 1428475622 [pv_total] + 100.00) [11] = = Array ([u_id] = 6 [UserID] = feng006 [Status] = 3 [C Onfirm_time] = 1428479200 [Pv_total] = 100.00) [] = = Array ([u_id] = > 6 [UserID] = feng006 [Status] = 3 [confirm_time] + 1428483519 [Pv_total] = 40.00); $count = count ($res); $sql = "INSERT into users (PERIODS,UID,USERNAME,PV) VALUES"; foreach ($res as $key = + $vo) {if ($key = = $count-1) {$sql. = "(". $periods. ",". $vo [' u_id ' ]. "," ". $vo [' userid ']." ', ". $vo [' Pv_total '].") "; }else{$sql. = "(". $periods. ",". $vo [' u_id ']. ", '". $vo [' UsErid ']. "',". $vo [' Pv_total ']. "),"; } }; M ()->query ($sql);
Is this going to work? Not much use of the bulk Operations database, please guide.
Reply content:
$arr = Array ([0] = = Array ([u_id] = 1 [UserID] = feng003 [status] = 3 [Confirm_time] = 1427940803 [Pv_total] = 0.00) [1] = = Array ( [U_ID] = 1 [UserID] = feng003 [Status] = 3 [Confirm_time] + 142 8477888 [Pv_total] = 0.00) [2] = = Array ([u_id] = 1 [userid ] = feng003 [Status] = 3 [Confirm_time] = 1428475892 [Pv_total] + 0.00 ) [3] = = Array ([u_id] = 2 [UserID] = feng001 [status] = 3 [Confirm_time] = 1428482901 [Pv_total] = 0.00) [4] = = Array ( [U_ID] = 2 [UserID] = feng001 [Status] = 3 [confirm_time] + 1428483116 [Pv_total] => 0.00) [5] = = Array ([u_id] = 1 [UserID] = feng003 [sta TUS] = 3 [Confirm_time] = 1428483542 [Pv_total] = 20.00) [6] = = Array ([u_id] = 1 [UserID] = feng003 [Status] = 3 [Confirm_time] =&G T 1428475881 [Pv_total] = 40.00) [7] = = Array ([u_id] = 5 [US Erid] = feng005 [Status] = 3 [Confirm_time] = 1428474458 [pv_total] + 100 . xx) [8] = = Array ([u_id] = 4 [UserID] = feng004 [status] = > 3 [Confirm_time] = 1428475275 [Pv_total] = 100.00) [9] = = Array ( [U_ID] = 3 [UserID] = feng002 [Status] = 3 [confirm_time] + 14 28475478 [Pv_total] = 100.00) [Ten] = = Array ([u_id] = 2 [UserID] = feng001 [Status] = 3 [Confirm_time] = 1428475622 [pv_total] + 100.00) [11] = = Array ([u_id] = 6 [UserID] = feng006 [Status] = 3 [C Onfirm_time] = 1428479200 [Pv_total] = 100.00) [] = = Array ([u_id] = > 6 [UserID] = feng006 [Status] = 3 [confirm_time] + 1428483519 [Pv_total] = 40.00); $count = count ($res); $sql = "INSERT into users (PERIODS,UID,USERNAME,PV) VALUES"; foreach ($res as $key = + $vo) {if ($key = = $count-1) {$sql. = "(". $periods. ",". $vo [' u_id ' ]. "," ". $vo [' userid ']." ', ". $vo [' Pv_total '].") "; }else{$sql. = "(". $periods. ",". $vo [' u_id ']. ", '". $vo [' UsErid ']. "',". $vo [' Pv_total ']. "),"; } }; M ()->query ($sql);
Is this going to work? Not much use of the bulk Operations database, please guide.
# # #代码大概像这样吧, hand-punched, no test # # #
php
$sql = 'INSERT INTO TABLE (`u_uid`, `userid`,`status`,`confirm_time`,`pv_total`) VALUES';foreach($arr as $k => $item) { $sql .= '(' . $item['u_uid'] . ',' . $item['userid'] . ',' . $item['status'] . ',' . $item['confirm_time'] . ',' . $item['pv_total'] . '),';}$sql = rtrim($sql, ',');
Yes, that's it.
sql
INSERT INTO table_name (列1, 列2,...) VALUES (值1, 值2,....),(值1, 值2,....),(值1, 值2,....)
In fact, programming this thing, you have to try to know that is not feasible.