sanitise data before inserting

This commit is contained in:
2017-06-29 13:03:10 +10:00
parent cd83d885d8
commit f4116040c1

View File

@@ -276,7 +276,15 @@ function booking_insert($node) {
watchdog('booking_debug', "<pre>Inserting node:\n@info</pre>", array('@info' => print_r($node, TRUE)));
//TODO: Generalise this by using the keys from $node instead of hard coding everything
db_insert('booking_person')->fields($node)->execute();
$data = array();
foreach ($node as $key => $value) {
//check if the key is a field that belongs in the database
if ((strpos($key, "booking_") === 0) || $key === "nid") {
$data[$key] = $value;
}
}
watchdog('booking_debug', "<pre>Sanitised data:\n@info</pre>", array('@info' => print_r($data, TRUE)));
db_insert('booking_person')->fields($data)->execute();
/*
db_insert('booking_person')