|
@@ -17,7 +17,7 @@
|
|
|
|
|
|
|
|
The Initial Developer of the Original Code is
|
|
The Initial Developer of the Original Code is
|
|
|
Mark J Crane <[email protected]>
|
|
Mark J Crane <[email protected]>
|
|
|
- Portions created by the Initial Developer are Copyright (C) 2008-2023
|
|
|
|
|
|
|
+ Portions created by the Initial Developer are Copyright (C) 2008-2025
|
|
|
the Initial Developer. All Rights Reserved.
|
|
the Initial Developer. All Rights Reserved.
|
|
|
|
|
|
|
|
Contributor(s):
|
|
Contributor(s):
|
|
@@ -34,6 +34,9 @@
|
|
|
exit;
|
|
exit;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+//connect to the database
|
|
|
|
|
+ $database = database::new();
|
|
|
|
|
+
|
|
|
//set the default values
|
|
//set the default values
|
|
|
if (isset($db_file_path) > 0) {
|
|
if (isset($db_file_path) > 0) {
|
|
|
$db_path = $db_file_path;
|
|
$db_path = $db_file_path;
|
|
@@ -45,7 +48,6 @@
|
|
|
$sql = "select * from v_databases ";
|
|
$sql = "select * from v_databases ";
|
|
|
$sql .= "where database_uuid = :database_uuid ";
|
|
$sql .= "where database_uuid = :database_uuid ";
|
|
|
$parameters['database_uuid'] = $_REQUEST['id'];
|
|
$parameters['database_uuid'] = $_REQUEST['id'];
|
|
|
- $database = new database;
|
|
|
|
|
$row = $database->select($sql, $parameters, 'row');
|
|
$row = $database->select($sql, $parameters, 'row');
|
|
|
if (is_array($row) && @sizeof($row) != 0) {
|
|
if (is_array($row) && @sizeof($row) != 0) {
|
|
|
$db_type = $row["database_type"];
|
|
$db_type = $row["database_type"];
|
|
@@ -70,29 +72,27 @@ if (!function_exists('get_db_field_names')) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// if we're still here, we need to try something else
|
|
// if we're still here, we need to try something else
|
|
|
- $fields = array();
|
|
|
|
|
|
|
+ $fields = array();
|
|
|
$driver = $db->getAttribute(PDO::ATTR_DRIVER_NAME);
|
|
$driver = $db->getAttribute(PDO::ATTR_DRIVER_NAME);
|
|
|
if ($driver == 'sqlite') {
|
|
if ($driver == 'sqlite') {
|
|
|
- $query = sprintf("Pragma table_info(%s);", $table);
|
|
|
|
|
- $stmt = $db->prepare($query);
|
|
|
|
|
- $result = $stmt->execute();
|
|
|
|
|
- $rows = $stmt->fetchAll(PDO::FETCH_NAMED);
|
|
|
|
|
|
|
+ $query = sprintf("Pragma table_info(%s);", $table);
|
|
|
|
|
+ $stmt = $db->prepare($query);
|
|
|
|
|
+ $result = $stmt->execute();
|
|
|
|
|
+ $rows = $stmt->fetchAll(PDO::FETCH_NAMED);
|
|
|
//printf('<pre>%s</pre>', print_r($rows, true));
|
|
//printf('<pre>%s</pre>', print_r($rows, true));
|
|
|
- $row_count = count($rows);
|
|
|
|
|
|
|
+ $row_count = count($rows);
|
|
|
//printf('<pre>%s</pre>', print_r($rows, true));
|
|
//printf('<pre>%s</pre>', print_r($rows, true));
|
|
|
for ($i = 0; $i < $row_count; $i++) {
|
|
for ($i = 0; $i < $row_count; $i++) {
|
|
|
array_push($fields, $rows[$i]['name']);
|
|
array_push($fields, $rows[$i]['name']);
|
|
|
}
|
|
}
|
|
|
return $fields;
|
|
return $fields;
|
|
|
- } else {
|
|
|
|
|
- $query = sprintf("SELECT * FROM information_schema.columns
|
|
|
|
|
- WHERE table_schema='%s' AND table_name='%s';"
|
|
|
|
|
- , $db_name, $table
|
|
|
|
|
- );
|
|
|
|
|
- $stmt = $db->prepare($query);
|
|
|
|
|
- $result = $stmt->execute();
|
|
|
|
|
- $rows = $stmt->fetchAll(PDO::FETCH_NAMED);
|
|
|
|
|
- $row_count = count($rows);
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ $query = sprintf("SELECT * FROM information_schema.columns WHERE table_schema='%s' AND table_name='%s';", $db_name, $table);
|
|
|
|
|
+ $stmt = $db->prepare($query);
|
|
|
|
|
+ $result = $stmt->execute();
|
|
|
|
|
+ $rows = $stmt->fetchAll(PDO::FETCH_NAMED);
|
|
|
|
|
+ $row_count= count($rows);
|
|
|
//printf('<pre>%s</pre>', print_r($rows, true));
|
|
//printf('<pre>%s</pre>', print_r($rows, true));
|
|
|
for ($i = 0; $i < $row_count; $i++) {
|
|
for ($i = 0; $i < $row_count; $i++) {
|
|
|
array_push($fields, $rows[$i]['COLUMN_NAME']);
|
|
array_push($fields, $rows[$i]['COLUMN_NAME']);
|
|
@@ -233,6 +233,4 @@ if ($db_type == "odbc") {
|
|
|
catch (PDOException $e) {
|
|
catch (PDOException $e) {
|
|
|
echo 'Connection failed: ' . $e->getMessage();
|
|
echo 'Connection failed: ' . $e->getMessage();
|
|
|
}
|
|
}
|
|
|
-} //end if db_type odbc
|
|
|
|
|
-
|
|
|
|
|
-?>
|
|
|
|
|
|
|
+} //end if db_type odbc
|