function _add fields array query INSERT INTO user SET Отрабатываем пол

 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
function _add($fields = array()){
$query = "INSERT INTO user SET ";
// Отрабатываем поля
$query_fields = array();
$query_params = array();
if(isset($fields['user_id'])){
$query_fields[] = 'user_id = ?';
$query_params[] = $fields['user_id'];
}
if(isset($fields['user_login'])){
$query_fields[] = 'user_login = ?';
$query_params[] = $fields['user_login'];
}
if(isset($fields['user_pass'])){
$query_fields[] = 'user_pass = ?';
$query_params[] = $fields['user_pass'];
}
if(isset($fields['user_email'])){
$query_fields[] = 'user_email = ?';
$query_params[] = $fields['user_email'];
}
if(isset($fields['user_url'])){
$query_fields[] = 'user_url = ?';
$query_params[] = $fields['user_url'];
}
if(isset($fields['user_in'])){
$query_fields[] = 'user_in = ?';
$query_params[] = $fields['user_in'];
}
if(isset($fields['user_out'])){
$query_fields[] = 'user_out = ?';
$query_params[] = $fields['user_out'];
}
if(isset($fields['user_cliks_real'])){
$query_fields[] = 'user_cliks_real = ?';
$query_params[] = $fields['user_cliks_real'];
}
if(isset($fields['user_cliks_first'])){
$query_fields[] = 'user_cliks_first = ?';
$query_params[] = $fields['user_cliks_first'];
}
if(isset($fields['user_force'])){
$query_fields[] = 'user_force = ?';
$query_params[] = $fields['user_force'];
}
if(isset($fields['user_access'])){
$query_fields[] = 'user_access = ?';
$query_params[] = $fields['user_access'];
}
if(isset($fields['user_date_reg'])){
$query_fields[] = 'user_date_reg = ?';
$query_params[] = $fields['user_date_reg'];
}
if(isset($fields['user_date_reg_now'])){
$query_fields[] = 'user_date_reg = NOW()';
}
if(count($query_fields)){
$query .= implode(',', $query_fields);
$this->DB->query($query, $query_params);
return mysql_insert_id();
}
}