Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Rotua Panjaitan
yii2
Commits
10af7f05
Commit
10af7f05
authored
May 09, 2014
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
guide WIP [skip ci]
parent
e1c27788
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
9 deletions
+32
-9
start-databases.md
docs/guide/start-databases.md
+32
-7
start-forms.md
docs/guide/start-forms.md
+0
-2
No files found.
docs/guide/start-databases.md
View file @
10af7f05
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.
To achieve this goal, you will create an
[
action
](
structure-controllers.md
)
, a
[
view
](
structure-views.md
)
,
and an
[
Active Record
](
db-active-record.md
)
model that can be used to fetch and represent database data.
To achieve this goal, you will configure the database connection, create an
[
Active Record
](
db-active-record.md
)
class
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
*
How to configure
database
connections;
*
How to configure
DB
connections;
*
How to define an Active Record class;
*
How to query data using the Active Record class;
*
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 a View
---------------
How It Works
------------
Summary
-------
docs/guide/start-forms.md
View file @
10af7f05
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.
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.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment