projects
/
misc
/
kostenrechnung
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
800b385
)
Add support for secondary tables for editing
author
Joey Schulze
<joey@infodrom.org>
Thu, 4 Mar 2010 21:15:47 +0000
(22:15 +0100)
committer
Joey Schulze
<joey@infodrom.org>
Thu, 4 Mar 2010 21:15:47 +0000
(22:15 +0100)
ajax/ajax.php
patch
|
blob
|
history
diff --git
a/ajax/ajax.php
b/ajax/ajax.php
index
4ab5aa2
..
2b1acac
100644
(file)
--- a/
ajax/ajax.php
+++ b/
ajax/ajax.php
@@
-101,9
+101,10
@@
function save($mask)
}
}
}
}
- $sql = 'UPDATE ' . $mask['table'] . ' SET ';
- $sql .= implode(', ', $update);
- $sql .= ' WHERE id = ' . intval($_POST['id']);
+ $sql = sprintf('UPDATE %s SET %s WHERE id = %d',
+ empty($mask['edit_table']) ? $mask['table'] : $mask['edit_table'],
+ implode(', ', $update),
+ intval($_POST['id']));
$sth = pg_query($sql);
$sth = pg_query($sql);
@@
-155,8
+156,10
@@
function insert($mask)
}
}
}
}
- $sql = 'INSERT INTO ' . $mask['table'] . ' (' . implode(',', $fields) . ') ';
- $sql .= 'VALUES (' . implode(',', $values) . ')';
+ $sql = sprintf('INSERT INTO %s (%s) VALUES (%s)',
+ empty($mask['edit_table']) ? $mask['table'] : $mask['edit_table'],
+ implode(',', $fields),
+ implode(',', $values));
$sth = pg_query($sql);
$sth = pg_query($sql);
@@
-174,6
+177,9
@@
function delete_or_copy($mask)
if (empty($_POST['id']))
return array('error' => 'Missing ID');
if (empty($_POST['id']))
return array('error' => 'Missing ID');
+ if (!empty($mask['edit_table']))
+ return array('error' => 'Cannot handle deletion for secondary table');
+
if (DELETE_COPY === true) {
$sql = sprintf("INSERT INTO %s_deleted SELECT * FROM %s WHERE id = %d",
$mask['table'], $mask['table'], $_POST['id']);
if (DELETE_COPY === true) {
$sql = sprintf("INSERT INTO %s_deleted SELECT * FROM %s WHERE id = %d",
$mask['table'], $mask['table'], $_POST['id']);