12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
- /*
- * 留存2
- */
- include_once dirname(__FILE__) . '/../main.php';
- $paras = query_paras();
- $startTime = $paras['date1'];
- $endTime = $paras['date2'];
- $type = $paras['type'];
- $endDate = strtotime("$endTime");
- $array = array();
- $labels = array();
- $tabName = "tab_rolename";
- for ($i = 0; $i <= 999; $i++) {
- $iday = strtotime("$startTime +$i day");
- $day = date("Y-m-d", $iday);
- if ($iday > $endDate) {
- break;
- }
- $labels[] = $day;
-
- $new = daoInst()->select('*')->from($tabName)
- ->where('ts')->ge($day . " 00:00:00")
- ->andWhere('ts')->le($day . " 23:59:59")
- ->count();
- if ($type == 0) {
- $array[] = $new;
- } else {
- $iday2 = strtotime("$day +$type day");
- $day2 = date("Y-m-d", $iday2);
- $total = daoInst()->select('*')->from($tabName)
- ->where('ts')->ge($day . " 00:00:00")
- ->andWhere('ts')->le($day . " 23:59:59")
- ->andWhere('lastlogin')->ge($day2 . " 00:00:00")
- ->count();
- $array[] = (int) ($total / $new * 100);
- }
- }
- $result = new stdClass();
- $result->data = $array;
- $result->labels = $labels;
- echo json_encode($result);
|