?
本文檔使用 php中文網(wǎng)手冊 發(fā)布
此案例研究演示了如何構建一個完整的 <AppML> 互聯(lián)網(wǎng)應用程序,具有針對數(shù)據(jù)庫中的若干表進行信息列舉、編輯和搜索的功能。
在本章中,我們將為數(shù)據(jù)庫中的每個表建立一個原型模型。
原型是非常便于使用的開發(fā)應用程序的起點。
首先,為原型創(chuàng)建一個文件夾。該文件夾命名為 Prototypes。
然后,為數(shù)據(jù)庫中的每個表創(chuàng)建一個原型模型。
使用 SELECT * from 每個表,并保存模型為 XML 文件:
<appml>
<datasource>
<database>
<connection>Demo</connection>
<sql>SELECT * FROM Customers</sql>
</database>
</datasource>
</appml>
<appml>
<datasource>
<database>
<connection>Demo</connection>
<sql>SELECT * FROM Suppliers</sql>
</database>
</datasource>
</appml>
<appml>
<datasource>
<database>
<connection>Demo</connection>
<sql>SELECT * FROM Products</sql>
</database>
</datasource>
</appml>
創(chuàng)建一個原型視圖,把它保存為 Demo_Prototype.html,并嘗試一下:
<h1>Customers</h1>
<div id="List01"></div>
<script src="appml.js"></script>
<script>
customers=new AppML("appml.php","Prototypes/Customers");
customers.run("List01");
</script>
最后,通過少量 JavaScript 編碼,為所有原型模型創(chuàng)建一個簡單的原型頁面:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="appml.css" />
</head>
<body>
<h1>Demo Applications</h1>
<button onclick='myOpen("Customers")'>Customers</button>
<button onclick='myOpen("Products")'>Products</button>
<button onclick='myOpen("Suppliers")'>Suppliers</button>
<button onclick='myOpen("Shippers")'>Shippers</button>
<button onclick='myOpen("Categories")'>Categories</button>
<button onclick='myOpen("Employees")'>Employees</button>
<button onclick='myOpen("Orders")'>Orders</button>
<button onclick='myOpen("OrderDetails")'>OrderDetails</button>
<br><br>
<div id="Place01"></div>
<script src="appml.js"></script>
<script>
function myOpen(pname)
{
var app_obj
app_obj=new AppML("appml.php","Prototypes/" + pname);
app_obj.run("Place01");
}
</script>
</body>
</html>