Extract data from the database for the last thirty days and generate the code for the bar chart. For more information, see.
Extract data from the database for the last thirty days and generate the code for the bar chart. For more information, see.
Run the cd command on the terminal to enter the file directory.
Note: here is an example of the project.
1. create a project: Enter zf create project Airline in the format of zf create action project-name in the terminal. Note: You can enter zf in the terminal to view the format.
2. create an action: zf create action dirgramshow index in the format of zf create action-name controller-name
3. create a model: zf create db-table flightinformation
Code at the action layer: indexController. php
The Code is as follows:
Public function indexAction ()
{
// Action body
$ Db = new Application_Model_DbTable_Flightinformation ();
/* Obtain the number of objects in the last 30 days.
* Select day (boo_time) as day, count (boo_autoid) as count, boo_time from bookinformation
Where flag_pass = 0 and date_sub (now (), interval 30 day) <= date (boo_time)
Group by DATE_FORMAT (boo_time, '% m % D ')
*/
$ SQL = "select DATE_FORMAT (boo_time, '% m-% D') as day, count (boo_autoid) as count from bookinformation ".
"Where flag_pass = 0 and date_sub (now (), interval 30 day) <= date (boo_time )".
"Group by DATE_FORMAT (boo_time, '% m % D ')";
$ Result = $ db-> getAllInfo ($ SQL)-> fetchAll ();
$ This-> view-> result = $ result;
}
View-Layer Code: dirgramshow. phtml
The Code is as follows:
Flight line chart