Add odbc support to the databases sql query tool.

This commit is contained in:
Mark Crane 2012-06-30 23:35:18 +00:00
parent 1c15037e0b
commit 14718825e0
3 changed files with 37 additions and 23 deletions

View File

@ -62,7 +62,6 @@ else {
echo "<div align='center'>";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='2'>\n";
echo "<tr class='border'>\n";
echo " <td align=\"left\">\n";
echo " <br>";

View File

@ -60,8 +60,7 @@ require_once "includes/paging.php";
echo "</table>\n";
//prepare to page the results
$sql = "";
$sql .= " select count(*) as num_rows from v_databases ";
$sql = "select count(*) as num_rows from v_databases ";
if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; }
$prep_statement = $db->prepare($sql);
if ($prep_statement) {
@ -84,10 +83,9 @@ require_once "includes/paging.php";
$offset = $rows_per_page * $page;
//get the list
$sql = "";
$sql .= " select * from v_databases ";
$sql = "select * from v_databases ";
if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; }
$sql .= " limit $rows_per_page offset $offset ";
$sql .= "limit $rows_per_page offset $offset ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
@ -110,7 +108,7 @@ require_once "includes/paging.php";
//echo th_order_by('database_path', 'Path', $order_by, $order);
echo th_order_by('database_description', 'Description', $order_by, $order);
echo "<td align='right' width='21'>\n";
//echo " <a href='db_edit.php' alt='add'>$v_link_label_add</a>\n";
//echo " <a href='database_edit.php' alt='add'>$v_link_label_add</a>\n";
echo "</td>\n";
echo "<tr>\n";
@ -125,7 +123,7 @@ require_once "includes/paging.php";
//echo " <td valign='top' class='".$row_style[$c]."'>".$row['database_path']."&nbsp;</td>\n";
echo " <td valign='top' class='row_stylebg'>".$row['database_description']."&nbsp;</td>\n";
echo " <td valign='top' align='right'>\n";
echo " <a href='v_sql_query.php?id=".$row['db_uuid']."' alt='edit'>$v_link_label_edit</a>\n";
echo " <a href='v_sql_query.php?id=".$row['database_uuid']."' alt='edit'>$v_link_label_edit</a>\n";
echo " </td>\n";
echo "</tr>\n";
if ($c==0) { $c=1; } else { $c=0; }

View File

@ -23,6 +23,16 @@
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
require_once "root.php";
require_once "includes/require.php";
require_once "includes/checkauth.php";
if (if_group("admin") || if_group("superadmin")) {
//access granted
}
else {
echo "access denied";
exit;
}
//set the default values
if (isset($db_file_path) > 0) {
@ -31,27 +41,23 @@
}
//get the db connection information
/*
if ($db) {
$sql = "";
$sql .= "select * from v_db ";
$sql .= "where domain_uuid = '$domain_uuid' ";
$sql .= "and db_uuid = '".$_REQUEST['id']."' ";
if (strlen($_REQUEST['id']) > 0) {
$sql = "select * from v_databases ";
$sql .= "where database_uuid = '".$_REQUEST['id']."' ";
$prep_statement = $db->prepare($sql);
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
foreach ($result as &$row) {
$db_type = $row["db_type"];
$db_host = $row["db_host"];
$db_port = $row["db_port"];
$db_name = $row["db_name"];
$db_username = $row["db_username"];
$db_password = $row["db_password"];
$db_path = $row["db_path"];
$db_type = $row["database_type"];
$db_host = $row["database_host"];
$db_port = $row["database_port"];
$db_name = $row["database_name"];
$db_username = $row["database_username"];
$db_password = $row["database_password"];
$db_path = $row["database_path"];
break;
}
}
*/
//unset the database connection
unset($db);
@ -222,4 +228,15 @@ if ($db_type == "pgsql") {
}
} //end if db_type pgsql
if ($db_type == "odbc") {
//database connection
try {
unset($db);
$db = new PDO("odbc:$db_name", "$db_username", "$db_password");
}
catch (PDOException $e) {
echo 'Connection failed: ' . $e->getMessage();
}
} //end if db_type odbc
?>