时间:2021-07-01 10:21:17 帮助过:19人阅读
从数据库中取出最近三十天的数据并生成柱状图的代码,需要的朋友可以参考下。
在终端用cd 命令进入文件目录
public function indexAction ()
{
// action body
$db = new Application_Model_DbTable_Flightinformation();
/*获取最近30天内的数目
* 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 层代码:dirgramshow.phtml
代码如下:
航班折线图