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

@@ -3028,3 +3028,20 @@ function array2XML($obj, $array)
}
}
}
function create_table_from_array($table,$arr) {
if(! ($arr && $table))
return false;
dbesc_array($arr);
$r = dbq("INSERT INTO " . TQUOT . $table . TQUOT . " (" . TQUOT
. implode(TQUOT . ', ' . TQUOT, array_keys($arr))
. TQUOT . ") VALUES ('"
. implode("', '", array_values($arr))
. "')" );
return $r;
}