一个SQL管理员的web接口
/*************************************************************************************
* SQLAdmin v2.0 - An SQL Administration User Interface for the Web *
* Copyright (C) 1997-98 Alessandro Vernet
*************************************************************************************
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; if not, write to the *
* Free Software Foundation, Inc., 59 Temple Place - Suite 330, *
* Boston, MA 02111-1307, USA. *
*************************************************************************************/
/* TODO:
* - Add sort order.
* - Add simple view.
* - Add some documentation.
*/
/* LIMITATIONS:
* - Works only with mSQL.
*/
/* HISTORY:
* - 97-11-05 (avernet) Corrected a bug with quote.
* - 98-01-01 (avernet) Added a sortColumn parameter to
* administrationTable function.
* - 98-03-14 (avernet) Added function addTable to enable users to
* add (but not modify) en entry to the database.
* - 98-05-19 (avernet) Submitted to PX.
* - 98-10-11 (avernet) Now SQLAdmin works with PHP3. The PHP2 version
* will not be mainteained anymore.
* - 98-10-11 (avernet) SQLAdmin is now distributed under the LGPL
* instead of MPL.
*/
function escapeforhtml ($string)
{
$result = $string;
//$result = ereg_replace ("\"", """, $result);
$result = ereg_replace (" $result = ereg_replace (">", ">", $result);
return $result;
}
function displayTuple ($fieldsNumber, $fieldNames,
$fieldLengths, $values, $mode)
{
$result = "";
$result .= "";
return $result;
}
function fieldFromType ($text, $type)
{
if ($type == "int" || $type == "uint" || $type == "real")
{ $result = $text; }
else
{ $result = "'" . AddSlashes ($text) . "'"; }
return $result;
}
function executeMsql ($database, $command)
{
/*echo "" . $command . "
";*/
msql ($database, $command);
}
function handleRemove ($database, $table, $fieldsNumber,
$fieldNames, $fieldLengths, $fieldTypes)
{
global $remove;
if ($remove != "")
{
$command = "DELETE FROM " . $table . " WHERE ";
$fieldIndex = 0;
while ($fieldIndex {
$fieldName = "old-" . $fieldNames [$fieldIndex];
global $$fieldName;
$command .= $fieldNames [$fieldIndex] . "=" .
fieldFromType ($$fieldName, $fieldTypes [$fieldIndex]);
if ($fieldIndex != $fieldsNumber - 1)
{ $command .= " AND "; }
$fieldIndex++;
}
executeMsql ($database, $command);
}
}
function handleUpdate ($database, $table, $fieldsNumber,
$fieldNames, $fieldLengths, $fieldTypes)
{
global $update;
if ($update != "")
{
$command = "UPDATE " . $table . " SET ";
$fieldIndex = 0;
while ($fieldIndex {
$fieldName = $fieldNames [$fieldIndex];
global $$fieldName;
$command .= $fieldName . "=" .
fieldFromType ($$fieldName, $fieldTypes [$fieldIndex]);
if ($fieldIndex != $fieldsNumber - 1)
{ $command .= ", "; }
$fieldIndex++;
}
$command .= " WHERE ";
$fieldIndex = 0;
while ($fieldIndex {
$fieldName = "old-" . $fieldNames [$fieldIndex];
global $$fieldName;
$command .= $fieldNames [$fieldIndex] . "=" .
fieldFromType ($$fieldName, $fieldTypes [$fieldIndex]);
if ($fieldIndex != $fieldsNumber - 1)
{ $command .= " AND "; }
$fieldIndex++;
}
executeMsql ($database, $command);
}
}
function handleAdd ($database, $table, $fieldsNumber,
$fieldNames, $fieldLengths, $fieldTypes)
{
global $add;
if ($add != "")
{
$command = "INSERT INTO " . $table . " (";
$fieldIndex = 0;
while ($fieldIndex {
$command .= $fieldNames [$fieldIndex];
if ($fieldIndex != $fieldsNumber - 1)
{ $command .= ", "; }
$fieldIndex++;
}
$command .= ") VALUES (";
$fieldIndex = 0;
while ($fieldIndex {
$fieldName = $fieldNames [$fieldIndex];
global $$fieldName;
$command .= fieldFromType ($$fieldName, $fieldTypes [$fieldIndex]);
if ($fieldIndex != $fieldsNumber - 1)
{ $command .= ", "; }
$fieldIndex++;
}
$command .= ")";
executeMsql ($database, $command);
}
}
function displayRemoveUpdate ($database, $table, $sortColumn,
$fieldsNumber, $fieldNames, $fieldLengths)
{
$result = "";
if ($sortColumn != "")
{ $sortColumn = " ORDER BY " . $sortColumn; }
$msqlresult = msql ($database, "SELECT * FROM " . $table . $sortColumn);
$tuplesNumber = msql_numrows ($msqlresult);
$tupleIndex = 0;
while ($tupleIndex {
$fieldIndex = 0;
while ($fieldIndex {
$values [$fieldIndex] = msql_result ($msqlresult, $tupleIndex,
$fieldNames [$fieldIndex]);
$fieldIndex++;
}
$result .= displayTuple ($fieldsNumber, $fieldNames,
$fieldLengths, $values, "modify");
$tupleIndex++;
}
return $result;
}
function displayAdd ($fieldsNumber, $fieldNames, $fieldLengths)
{
$result = "";
$fieldIndex = 0;
while ($fieldIndex {
$values [$fieldIndex] = "";
$fieldIndex++;
}
$result .= displayTuple ($fieldsNumber, $fieldNames,
$fieldLengths, $values, "add");
msql_close ();
return $result;
}
function administrationTable ($database, $table, $sortColumn)
{
$result = "";
msql_connect ( "localhost");
$msqlresult = msql ($database, "SELECT * FROM " . $table);
$fieldsNumber = msql_numfields ($msqlresult);
$msqlresult = msql_listfields ($database, $table);
$fieldIndex = 0;
while ($fieldIndex {
$fieldNames [$fieldIndex] = msql_fieldname ($msqlresult, $fieldIndex);
$fieldLengths [$fieldIndex] = msql_fieldlen ($msqlresult, $fieldIndex);
$fieldTypes [$fieldIndex] = msql_fieldtype ($msqlresult, $fieldIndex);
$fieldIndex++;
}
handleRemove ($database, $table, $fieldsNumber, $fieldNames, $fieldLengths, $fieldTypes);
handleUpdate ($database, $table, $fieldsNumber, $fieldNames, $fieldLengths, $fieldTypes);
handleAdd ($database, $table, $fieldsNumber, $fieldNames, $fieldLengths, $fieldTypes);
$result .= displayRemoveUpdate ($database, $table, $sortColumn, $fieldsNumber, $fieldNames,
$fieldLengths);
$result .= displayAdd ($fieldsNumber, $fieldNames, $fieldLengths);
return $result;
}
function addTable ($database, $table)
{
$result = "";
msql_connect ( "localhost");
$msqlresult = msql ($database, "SELECT * FROM " . $table);
$fieldsNumber = msql_numfields ($msqlresult);
$msqlresult = msql_listfields ($database, $table);
$fieldIndex = 0;
while ($fieldIndex {
$fieldNames [$fieldIndex] = msql_fieldname ($msqlresult, $fieldIndex);
$fieldLengths [$fieldIndex] = msql_fieldlen ($msqlresult, $fieldIndex);
$fieldTypes [$fieldIndex] = msql_fieldtype ($msqlresult, $fieldIndex);
$fieldIndex++;
}
handleAdd ($database, $table, $fieldsNumber, $fieldNames, $fieldLengths, $fieldTypes);
$result .= displayAdd ($fieldsNumber, $fieldNames, $fieldLengths);
return $result;
}
?>

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

當使用Win11系統時,有時會遇到需要輸入管理員使用者名稱和密碼的提示,本文將探討在遇到這種情況時應該如何處理。方法一:1、點選【Windows標誌】,然後按【Shift+重啟】進入安全模式;或這樣進入安全模式:點選開始選單,選擇設定。選擇「更新與安全」;選擇「恢復」中的「立即重新啟動」;重新啟動進入選項後選擇-疑難排解-進階選項-啟動設定—&mdash

HQL和SQL在Hibernate框架中進行比較:HQL(1.物件導向語法,2.資料庫無關的查詢,3.類型安全),而SQL直接操作資料庫(1.與資料庫無關的標準,2.可執行複雜查詢和資料操作)。

我們在電腦組裝的過程中,安裝過程雖然簡單,不過往往都是在接線上遇到問題,經常有裝機用戶誤將CPU散熱器的供電線插到了SYS_FAN上,雖然風扇可以轉動,不過在開機可能會有F1報錯“CPUFanError”,同時也導致了CPU散熱器無法智慧調速。下面裝機之家分享一下電腦主機板上CPU_FAN、SYS_FAN、CHA_FAN、CPU_OPT介面知識科普。電腦主機板上CPU_FAN、SYS_FAN、CHA_FAN、CPU_OPT介面知識科普1、CPU_FANCPU_FAN是CPU散熱器專用接口,12V工作

PHP介面簡介及其定義方式PHP是一種廣泛應用於Web開發的開源腳本語言,具有靈活、簡單、強大等特性。在PHP中,介面(interface)是一種定義多個類別之間公共方法的工具,實現了多態性,讓程式碼更加靈活和可重複使用。本文將介紹PHP介面的概念及其定義方式,同時提供具體的程式碼範例展示其用法。 1.PHP介面概念介面在物件導向程式設計中扮演著重要的角色,定義了類別應

Cockpit是一個面向Linux伺服器的基於Web的圖形介面。它主要是為了使新用戶/專家用戶更容易管理Linux伺服器。在本文中,我們將討論Cockpit存取模式以及如何從CockpitWebUI切換Cockpit的管理存取。內容主題:駕駛艙進入模式查找當前駕駛艙訪問模式從CockpitWebUI啟用Cockpit的管理訪問從CockpitWebUI禁用Cockpit的管理訪問結論駕駛艙進入模式駕駛艙有兩種訪問模式:受限訪問:這是駕駛艙的默認訪問模式。在這種存取模式下,您無法從駕駛艙Web用戶

MySQL連線數對資料庫效能的影響分析隨著網路應用的不斷發展,資料庫成為了支援應用系統重要的資料儲存和管理工具。在資料庫系統中,連線數是一個重要的概念,它直接關係到資料庫系統的效能和穩定性。本文將從MySQL資料庫的角度出發,探討連線數對資料庫效能的影響,並透過具體的程式碼範例進行分析。一、連線數是什麼?連線數指的是資料庫系統同時支援的客戶端連線數,也可以理

介面和抽象類別在設計模式中用於解耦和可擴展性。介面定義方法簽名,抽象類別提供部分實現,子類別必須實作未實現的方法。在策略模式中,介面用於定義演算法,抽象類別或具體類別提供實現,允許動態切換演算法。在觀察者模式中,介面用於定義觀察者行為,抽象類別或具體類別用於訂閱和發布通知。在適配器模式中,介面用於適應現有類,抽象類或具體類可實現相容接口,允許與原有程式碼互動。

PHP在Web開發中是屬於後端。 PHP是一種伺服器端腳本語言,主要用於處理伺服器端的邏輯,產生動態網頁內容。與前端技術相比,PHP更多地用於與資料庫互動、處理使用者請求以及生成頁面內容等後端操作。接下來透過具體的程式碼範例來說明PHP在後端開發中的應用。首先,我們來看一個簡單的PHP程式碼範例,用於連接資料庫並查詢資料:
