Commit 10af7f05 by Qiang Xue

guide WIP [skip ci]

parent e1c27788
Working with Databases Working with Databases
====================== ======================
> Note: This section is under development.
In this section, we will describe how to create a new page to display data fetched from a database table. In this section, we will describe how to create a new page to display data fetched from a database table.
To achieve this goal, you will create an [action](structure-controllers.md), a [view](structure-views.md), To achieve this goal, you will configure the database connection, create an [Active Record](db-active-record.md) class
and an [Active Record](db-active-record.md) model that can be used to fetch and represent database data. to fetch and represent database data, and then create an [action](structure-controllers.md) and
a [view](structure-views.md) to present the data to end users.
Through this tutorial, you will learn Through this tutorial, you will learn
* How to configure database connections; * How to configure DB connections;
* How to define an Active Record class; * How to define an Active Record class;
* How to query data using the Active Record class; * How to query data using the Active Record class;
* How to display data in a view in a paginated fashion. * How to display data in a view in a paginated fashion.
Note that in order to finish this section, you should have basic knowledge and experience about databases.
You should know how to create a database and how to execute SQL statements using a DB client tool.
Configuring a Database Connection
---------------------------------
To start, you should have a database ready. It can be a SQLite, MySQL, PostgreSQL, MSSQL or Oracle database.
For simplicity, in the following description, we will assume that you already have a MySQL database named `basic`.
Create a table named `address` and insert some sample data. The SQL statements are showing as follows,
```sql
CREATE TABLE `address` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`street` varchar(128),
`city` varchar(128),
`state` varchar(128),
`country` varchar(128)
);
```
Creating an Active Record
-------------------------
Creating a Model
----------------
Creating an Action Creating an Action
------------------ ------------------
Creating a View Creating a View
--------------- ---------------
How It Works How It Works
------------ ------------
Summary Summary
------- -------
Working with Forms Working with Forms
================== ==================
> Note: This section is under development.
In this section, we will describe how to create a new page to get data from users. In this section, we will describe how to create a new page to get data from users.
The page will display a form with a name input field and an email input field. The page will display a form with a name input field and an email input field.
After getting these data from a user, the page will echo them back to the user for confirmation. After getting these data from a user, the page will echo them back to the user for confirmation.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment