Update database.php
This commit is contained in:
parent
92f1bcdc4c
commit
d5ebe489bb
|
|
@ -1192,11 +1192,13 @@ include "root.php";
|
|||
|
||||
//get the parent field names
|
||||
$parent_field_names = array();
|
||||
if (is_array($array)) foreach ($array as $key => $value) {
|
||||
if (is_array($array)) {
|
||||
foreach ($array as $key => $value) {
|
||||
if (!is_array($value)) {
|
||||
$parent_field_names[] = preg_replace('#[^a-zA-Z0-9_\-]#', '', $key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//determine action update or delete and get the original data
|
||||
if ($parent_key_exists) {
|
||||
|
|
@ -1245,19 +1247,22 @@ include "root.php";
|
|||
//foreach ($parent_field_names as $field_name) {
|
||||
// $sql .= check_str($field_name).", ";
|
||||
//}
|
||||
if (is_array($array)) foreach ($array as $array_key => $array_value) {
|
||||
if (is_array($array)) {
|
||||
foreach ($array as $array_key => $array_value) {
|
||||
if (!is_array($array_value)) {
|
||||
$array_key = preg_replace('#[^a-zA-Z0-9_\-]#', '', $array_key);
|
||||
$sql .= $array_key.", ";
|
||||
}
|
||||
}
|
||||
}
|
||||
$sql .= ") ";
|
||||
$sql .= "VALUES ";
|
||||
$sql .= "(";
|
||||
if (!$parent_key_exists) {
|
||||
$sql .= "'".$parent_key_value."', ";
|
||||
}
|
||||
if (is_array($array)) foreach ($array as $array_key => $array_value) {
|
||||
if (is_array($array)) {
|
||||
foreach ($array as $array_key => $array_value) {
|
||||
if (!is_array($array_value)) {
|
||||
if (strlen($array_value) == 0) {
|
||||
$sql .= "null, ";
|
||||
|
|
@ -1272,6 +1277,7 @@ include "root.php";
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$sql .= ");";
|
||||
$sql = str_replace(", )", ")", $sql);
|
||||
|
||||
|
|
@ -1409,7 +1415,8 @@ include "root.php";
|
|||
unset($sql, $action);
|
||||
|
||||
//child data
|
||||
if (is_array($array)) foreach ($array as $key => $value) {
|
||||
if (is_array($array)) {
|
||||
foreach ($array as $key => $value) {
|
||||
|
||||
if (is_array($value)) {
|
||||
$table_name = "v_".$key;
|
||||
|
|
@ -1446,11 +1453,13 @@ include "root.php";
|
|||
|
||||
//get the child field names
|
||||
$child_field_names = array();
|
||||
if (is_array($row)) foreach ($row as $k => $v) {
|
||||
if (is_array($row)) {
|
||||
foreach ($row as $k => $v) {
|
||||
if (!is_array($v)) {
|
||||
$child_field_names[] = preg_replace('#[^a-zA-Z0-9_\-]#', '', $k);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//determine sql update or delete and get the original data
|
||||
if ($uuid_exists) {
|
||||
|
|
@ -1479,7 +1488,7 @@ include "root.php";
|
|||
$action = "add";
|
||||
}
|
||||
|
||||
//update the data
|
||||
//update the child data
|
||||
if ($action == "update") {
|
||||
if (permission_exists($child_name.'_edit')) {
|
||||
$sql = "UPDATE ".$table_name." SET ";
|
||||
|
|
@ -1556,7 +1565,7 @@ include "root.php";
|
|||
}
|
||||
} //action update
|
||||
|
||||
//add the data
|
||||
//add the child data
|
||||
if ($action == "add") {
|
||||
if (permission_exists($child_name.'_add')) {
|
||||
//determine if child or parent key exists
|
||||
|
|
@ -1678,6 +1687,7 @@ include "root.php";
|
|||
|
||||
} //is array
|
||||
} //foreach array
|
||||
}
|
||||
|
||||
} // foreach schema_array
|
||||
} // foreach main array
|
||||
|
|
|
|||
Loading…
Reference in New Issue