HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
The "database" property defines a database as the data source. It has the following sub properties
The "database" property defines a database as the data source. It has the following sub properties:
Element | Description |
---|---|
"connection" | The name of a database connection |
"execute" | Array of SQL statements to be executed before data retrieval (optional) |
"keyfield" | The key field for the main table (optional) |
"maintable" | The main table for this application (optional) |
"orderby" | A fixed SQL orderby clause for the application (optional) |
"sql" | The SQL statement for retrieving data |
This model fetches records containing Customer, City, and Country from a Customer table in an SQL database:
{
"database": {
"connection": "mysql",
"sql" :
"SELECT CustomerName, City, Country FROM Customers",
"orderby" : "CustomerName"
}
}
To allow users to filter data, you can add filter information to the model:
"filteritems" : [
{"item" : "CustomerName", "label" : "Customer"},
{"item" : "City"},
{"item" : "Country"}]
To allow users to sort data, you can add sort information to the model:
"sortitems" : [
{"item" : "CustomerName", "label" : "Customer"},
{"item" : "City"},
{"item" : "Country"}]
To allow users to update data, you can include update information in the model:
"updateItems" : [
{"item" : "CustomerName"},
{"item" : "Address"},
{"item" : "PostalCode"},
{"item" : "City"},
{"item" : "Country"}]
By default, AppML will let you filter, sort, or update data, only it is specified in the model.
Database connections are defined in appml_config:
<?php echo("Access Forbidden");exit();?>
{
"dateformat" : "yyyy-mm-dd",
"databases": [
{
"connection" : "mysql",
"host"
: "127.0.0.1:3306",
"dbname" : "Northwind",
"username"
: "myUserId",
"password" : "myPassword"
},
{
"connection" : "googleDB",
"host" :
"192.168.1.1:3306",
"dbname" : "Northwind",
"username"
: "myUserId",
"password" : "myPassword"
},
{
"connection" : "amazonDB",
"host" :
"mydbinstance.amazon.com:3306",
"dbname" : "Northwind",
"username" : "myUserId",
"password" : "myPassword"
},
{
"connection" : "azureDB",
"host" :
"azure.cloudapp.net",
"dbname" : "Northwind",
"username" :
"myUserId",
"password" : "myPassword"
}
]
}
The configuration file can contain many database connections.
Since AppML allows you to execute SQL statements before the application is started, you can use this to create a database if needed:
{
"database" : {
"connection" : "myCDs",
"execute" : [
"DROP
TABLE IF EXISTS CD_Catalog",
"CREATE TABLE IF NOT EXISTS CD_Catalog (CDID
INT NOT NULL AUTO_INCREMENT,PRIMARY KEY (CDID),Title NVARCHAR(255),Artist NVARCHAR(255),Country NVARCHAR(255),Price
NUMBER)"
]
}}
Perfect for rapid prototyping!