- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 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
public static function perform($table, $data, $action = 'insert', $parameters = '') {
reset($data);
if ($action == 'insert') {
$query = 'INSERT INTO ' . $table . ' (';
while (list($columns, ) = each($data)) {
$query .= $columns . ', ';
}
$query = substr($query, 0, -2) . ') values (';
reset($data);
while (list(, $value) = each($data)) {
switch ((string)$value) {
case 'now()':
$query .= 'NOW(), ';
break;
case 'null':
$query .= 'NULL, ';
break;
default:
$query .= '\'' . mysql_escape_string($value) . '\', ';
break;
}
}
$query = substr($query, 0, -2) . ')';
} elseif ($action == 'update') {
$query = 'UPDATE ' . $table . ' SET ';
while (list($columns, $value) = each($data)) {
switch ((string)$value) {
case 'now()':
$query .= $columns . ' = NOW(), ';
break;
case 'null':
$query .= $columns .= ' = NULL, ';
break;
default:
$query .= $columns . ' = \'' . mysql_escape_string($value) . '\', ';
break;
}
}
$query = substr($query, 0, -2) . ' WHERE ' . $parameters;
}
self::request($query);
}