コード例 #1
0
ファイル: index.php プロジェクト: jacoobwang/ecp
        $stmt = $db->prepare($sql . buildDateSql('all'));
        $stmt->execute();
        $all = $stmt->fetchColumn();
        $db = null;
        $data = array('day' => $day, 'prev' => $prev, 'week' => $week, 'next' => $next, 'month' => $month, 'pmonth' => $pmonth, 'ppmonth' => $ppmonth, 'all' => $all);
        echo '{"summary":' . json_encode($data) . '}';
    } catch (PDOException $e) {
        echo '{"error":{"text":"' . $e->getMessage() . '"}}';
    }
});
/**
 *  获取数量总数
 */
$app->get('/require/summary_bak/:state', function ($state) use($app) {
    //buildDateSql();
    $sql = 'select count(require_id) from tb_require_bak where  ' . buildStateSql($state) . ' and `is_del` = 0 ';
    try {
        $db = getConnection();
        //上周
        $stmt = $db->prepare($sql . buildDateSql('day'));
        $stmt->execute();
        $day = $stmt->fetchColumn();
        //上周
        $stmt = $db->prepare($sql . buildDateSql('prev'));
        $stmt->execute();
        $prev = $stmt->fetchColumn();
        //本周
        $stmt = $db->prepare($sql . buildDateSql('week'));
        $stmt->execute();
        $week = $stmt->fetchColumn();
        //下周
コード例 #2
0
ファイル: functions.php プロジェクト: jacoobwang/ecp
/**
 *  搜索页面sql组装
 */
function buildSearchSql($data)
{
    $sql = ' and `is_del` = 0 ';
    if ($data['require_id'] != '') {
        $sql .= " and `require_id` in( " . $data['require_id'] . ")";
    }
    if ($data['require_name'] != '') {
        $sql .= " and `require_name` LIKE  '%" . $data['require_name'] . "%' ";
    }
    if ($data['require_rank_id'] != '') {
        $sql .= " and `require_rank_id` in( " . $data['require_rank_id'] . ")";
        //    if( $data['require_rank_id'] == 200 ){
        //
        //        }else{
        //            $sql.= " and `require_rank_id` = " . $data['require_rank_id'] ;
        //        }
    }
    if ($data['require_type_id'] != '') {
        $sql .= " and `require_type_id` = " . $data['require_type_id'];
    }
    if ($data['require_workload'] != '') {
        $sql .= " and `require_workload` = " . $data['require_workload'];
    }
    //if(  $data['require_creator'] != ''){
    //$sql.= " and '".$data['require_creator']."' LIKE CONCAT('%',require_creator,'%')";//`require_creator` in (
    //};
    //fixed creator bug p_jdyhwei
    if ($data['require_creator'] != '') {
        $sql .= " and `require_creator` LIKE CONCAT('%" . $data['require_creator'] . "%')";
        //`require_creator` in (
    }
    if (isset($data['require_verify_user']) && $data['require_verify_user'] != '') {
        $sql .= " and `require_verify_user` LIKE  '%" . $data['require_verify_user'] . "%' ";
    }
    if (isset($data['require_cp_id']) && $data['require_cp_id'] != '') {
        $sql .= " and `require_cp_id` in( " . $data['require_cp_id'] . ")";
    }
    if ($data['require_state'] != '') {
        $sql .= " and " . buildStateSql($data['require_state']);
    }
    if (isset($data['require_rating']) && $data['require_rating'] != '') {
        $sql .= " and `require_rating` = '" . $data['require_rating'] . "'";
    }
    if ($data['require_type'] != '') {
        $sql .= " and `require_type` = " . $data['require_type'];
    }
    if ($data['require_rank_cate_id'] != '') {
        $sql .= " and `require_rank_cate_id` = " . $data['require_rank_cate_id'];
    }
    if ($data['require_pm_cost'] != '') {
        $pm_change = $data['require_pm_cost'];
        if ($pm_change == 0) {
            $sql .= " and `require_pm_cost` = 0";
        } else {
            $sql .= " and `require_pm_cost` != 0";
        }
    }
    if ($data['require_start_date'] != '' && $data['require_finish_date'] != '') {
        $sql .= " and DATE_FORMAT(tb_require.require_start_date,'%Y-%m-%d') >= '" . $data['require_start_date'] . "' and DATE_FORMAT(tb_require.require_start_date,'%Y-%m-%d') <= '" . $data['require_finish_date'] . "' ";
    }
    if ($data['is_modify_attr'] != '') {
        $sql .= " and `is_modify_attr` = " . $data['is_modify_attr'];
    }
    //echo $sql;
    return $sql;
}