Extract data from the database for the last 30 days and generate a bar chart _ MySQL

Source: Internet
Author: User
Extract data from the database for the last thirty days and generate a bar chart bitsCN.com. 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

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





Flight Line chart

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.