consolidate duplicated code for creating table entries from an array
This commit is contained in:
@@ -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;
|
||||
|
||||
}
|
Reference in New Issue
Block a user