consolidate duplicated code for creating table entries from an array

This commit is contained in:
zotlabs
2016-10-12 22:12:58 -07:00
parent e314510005
commit 48026efddf
4 changed files with 51 additions and 161 deletions

View File

@@ -1853,13 +1853,8 @@ function item_store($arr, $allow_exec = false, $deliver = true) {
logger('item_store: ' . print_r($arr,true), LOGGER_DATA);
dbesc_array($arr);
$r = dbq("INSERT INTO " . TQUOT . 'item' . TQUOT . " (" . TQUOT
. implode(TQUOT . ', ' . TQUOT, array_keys($arr))
. TQUOT . ") VALUES ('"
. implode("', '", array_values($arr))
. "')" );
create_table_from_array('item',$arr);
// find the item we just created
@@ -3088,15 +3083,9 @@ function mail_store($arr) {
return 0;
}
dbesc_array($arr);
logger('mail_store: ' . print_r($arr,true), LOGGER_DATA);
$r = dbq("INSERT INTO mail (" . TQUOT
. implode(TQUOT . ', ' . TQUOT, array_keys($arr))
. TQUOT . ") VALUES ('"
. implode("', '", array_values($arr))
. "')" );
create_table_from_array('mail', $arr);
// find the item we just created