public static function configure_database(array $array) { $DBINUSE = Database\DATABASE::$database_in_use_ns . Database\DATABASE::$database_in_use; $make_table = []; if (self::has_attribute($array, "name", true)) { $make_column = []; $make_column["@attributes"] = []; foreach ($array as $col_key => $col_value) { if (self::startswith(strtolower($col_key), "column:")) { if (self::has_attribute($col_value, "name", true) && self::has_attribute($col_value, "type", true)) { $attributes = $col_value["@attributes"]; $autoincrement = self::has_attribute($col_value, "autoincrement"); $primarykey = self::has_attribute($col_value, "primarykey"); $autoincrementval = $autoincrement ? $DBINUSE::create_column_autoincrement() : ""; $primarykeyval = $primarykey ? $DBINUSE::create_column_primarykey($attributes["name"]) : ""; $type = $DBINUSE::create_column_type($attributes["type"]); $length = self::has_attribute($col_value, "length", true) ? $DBINUSE::create_column_length($attributes["length"]) : ""; $null = self::has_attribute($col_value, "null", true) ? $DBINUSE::create_column_null(UTIL::bool_val($attributes["null"])) : ""; $default = self::has_attribute($col_value, "default", true) ? $DBINUSE::create_column_default($attributes["default"]) : ""; $create = ["type" => $type, "length" => $length, "null" => $null, "default" => $default, "autoincrementval" => $autoincrementval, "primarykeyval" => $primarykeyval, "primarykeyval" => $primarykeyval]; $make_column[$col_value["@attributes"]["name"]]["sql"] = $create; } } } $make_column["@attributes"]["name"] = $array["@attributes"]["name"]; $make_column["@attributes"]["create"] = self::has_attribute($array, "create", true) ? UTIL::bool_val($array["@attributes"]["create"]) : false; $make_column["@attributes"]["createcolumns"] = self::has_attribute($array, "createcolumns", true) ? UTIL::bool_val($array["@attributes"]["createcolumns"]) : false; $make_column["@attributes"]["dropcolumns"] = self::has_attribute($array, "dropcolumns", true) ? UTIL::bool_val($array["@attributes"]["dropcolumns"]) : false; $make_column["@attributes"]["tablespec"] = self::has_attribute($array, "tablespec", true) ? $array["@attributes"]["tablespec"] : ""; $make_column["@attributes"]["createsequence"] = self::has_attribute($array, "createsequence", true) ? UTIL::bool_val($array["@attributes"]["createsequence"]) : false; $make_column["@attributes"]["sequencename"] = self::has_attribute($array, "sequencename", true) ? $array["@attributes"]["sequencename"] : ""; $make_table[$array["@attributes"]["name"]] = $make_column; } if (!empty($make_table)) { $DBINUSE::create_table($make_table); } }
private static function returnval($value, $returntype) { if (is_int($returntype)) { return $value == "" ? 0 : intval($value); } if (is_bool($returntype)) { return $value == "" ? false : UTIL::bool_val($value); } if (is_array($returntype)) { return $value == "" ? [] : $value; } return strval($value); }