-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathteste_update_array.php
More file actions
42 lines (35 loc) · 906 Bytes
/
teste_update_array.php
File metadata and controls
42 lines (35 loc) · 906 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
/*
Jamais faça um UPDATE SEM WHERE...
*/
$ins=array(
array(
'nome'=>'Andre',
'email'=>'[email protected]',
'idade'=>'43',
'senha'=>'123'
),array(
'nome'=>'José',
'email'=>'[email protected]',
'idade'=>'50',
'senha'=>'321'
),array(
'nome'=>'Maria',
'email'=>'[email protected]',
'idade'=>'22',
'senha'=>'456'
)
);
//print_r($ins[1]); exit;
for ($i=0; $i < count($ins); $i++) {
$id = 1;
$valores='';
$campo='';
foreach ($ins[$i] as $key => $value) {
$campo .=$key.'=';
$campo .="'$value',";
}
$insertInto = substr($campo,0,-1);
echo "<br>sql = UPDATE tb_name SET $insertInto WHERE id = $id";
}
?>