From 48026efddfdf063fad7c7bd7a86dd7fc4ca4a0a7 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 12 Oct 2016 22:12:58 -0700 Subject: consolidate duplicated code for creating table entries from an array --- include/text.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'include/text.php') diff --git a/include/text.php b/include/text.php index 6d5b72f49..f23458db0 100644 --- a/include/text.php +++ b/include/text.php @@ -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; + +} \ No newline at end of file -- cgit v1.2.3