이 글은 주로 thinkPHP 거래 내역 조회 기능을 소개하고, thinkPHP 데이터베이스 조회 기능을 분석하고, 출력 관련 연산 스킬을 예시 형태로 보여줍니다. 도움이 필요한 친구들이 참고할 수 있습니다.
이 글은 thinkPHP 거래 내역 조회 기능을 예시로 분석합니다. 예. 참고할 수 있도록 모든 사람과 공유하세요. 세부정보는 다음과 같습니다.
거래 세부정보
는 일반적으로 거래 날짜, 거래 금액, 거래 상태(선택 사항 여부)
총 거래 금액 등을 포함하여 월 단위입니다.
데이터가 많으면 페이지를 매기는 것이 가장 좋습니다.
특정 가맹점을 확인하시는 것이 가장 좋습니다.
1. SQL을 시뮬레이션하여 쿼리 기능을 구현합니다
SELECT a.id as user_id,a.username,b.name as store_name,c.id as order_id,c.price,c.paytime,c.sendtime,c.receivetime FROM sh_user a LEFT JOIN sh_store b on a.id = b.user_id LEFT JOIN sh_order c ON b.id = c.store_id WHERE a.opener_id = 1 and a.`status` = 1 and c.status = 1 ORDER BY c.id desc; SELECT count(b.id) as count ,sum(c.price) as total_price FROM sh_user a LEFT JOIN sh_store b on a.id = b.user_id LEFT JOIN sh_order c ON b.id = c.store_id WHERE a.opener_id = 1 and a.`status` = 1 and c.status = 1;
SQL 쿼리는 기본적으로 완료되었으며, 나머지는 php와 thinkphp를 사용하여 쿼리 기능을 구현하고 몇 가지 로직과 조건을 추가하는 것입니다.
// 商户交易 public function trade(){ if($type = $this->_request('type','trim')){ $s_year = $this->_request('s_year','trim'); $s_month = $this->_request('s_month','trim'); $s_user_id = $this->_request('s_user_id','trim,intval'); $this->assign('s_user_id',$s_user_id); if($type == 'last'){ // 获取上一月 if($s_month==1){ $useYear = $s_year-1; $useMonth = 12; }else{ $useYear = $s_year; $useMonth = $s_month-1; } } if($type == 'next'){ // 获取下一月 if($s_month==12){ $useYear = $s_year+1; $useMonth = 1; }else{ $useYear = $s_year; $useMonth = $s_month+1; } } if ($type == 'selectuser'){ $useYear = $s_year; $useMonth = $s_month; } }else{ // 获取当前年 月 $useYear = date('Y'); $useMonth = date('m'); } $this->assign('s_year',$useYear); $this->assign('s_month',$useMonth); $b_time = strtotime($useYear.'-'.$useMonth.'-'.'1'); $e_time = strtotime($useYear.'-'.$useMonth.'-'.date('t',strtotime($b_time)).' 23:59:59'); if(isset($s_user_id) && $s_user_id > 0){ $where['a.id'] = $s_user_id; } $where['a.opener_id'] = $this->opener_id; $where['a.status'] = 1; // 合法的用户 $where['c.status'] = 1; // 合法的订单 $where['c.paytime'] = array(array('gt',$b_time),array('lt',$e_time),'and'); $count_and_totalprice = M()->table('sh_user a') ->join('sh_store b on a.id = b.user_id') ->join('sh_order c on b.id = c.store_id') ->where($where) ->field('count(b.id) as count ,sum(c.price) as totalprice') ->find(); $count = $count_and_totalprice['count']; $totalprice = $count_and_totalprice['totalprice'] ? $count_and_totalprice['totalprice'] : 0; $Page = new Page($count, 10); $list = M()->table('sh_user a') ->join('sh_store b on a.id = b.user_id') ->join('sh_order c on b.id = c.store_id') ->where($where) ->order('c.id desc') ->limit($Page->firstRow.','.$Page->listRows) ->field('a.id as user_id,a.username,b.name as store_name,c.id as order_id,c.price,c.paytime,c.sendtime,c.receivetime') ->select(); foreach ($list as $k => $v) { if($v['sendtime'] == 0 && $v['receivetime'] == 0){ $list[$k]['progress'] = '1'; // 已付款,待发货 } if($v['sendtime'] > 0 && $v['receivetime'] == 0){ $list[$k]['progress'] = '2'; // 已发货,待签收 } if($v['sendtime'] > 0 && $v['receivetime'] > 0){ $list[$k]['progress'] = '3'; // 交易完成 } } // 获取拓展员用户 $user_list = M('User') ->where(array('opener_id'=>$this->opener_id)) ->field('id,username') ->select(); $this->assign('user_list',$user_list); $this->assign('totalprice',$totalprice); $this->assign('page',$Page->show()); $this->assign('list', $list); $this->display(); }
html part
<include file="Public:head" title="交易详情" /> <style> .top { background-color: #eee; height: 50px; line-height: 50px; font-size: 18px; border-bottom: #ddd 1px solid; margin-bottom: -1px; } .list-group{ border: 1px solid #DDDDDD; } .list-group .list-group-item { text-align: left; line-height: 25px; border: none; background-color: #F9F9F9; font-size: 14px; } #select-date { padding: 0px 10px; } #select-date .date-txt { font-size: 18px; } #total { width: 140px; height: 140px; background-color: #EC6C00; margin: auto; } #total .money-txt { color: white; padding-top: 10px; } #datalist { margin-top: 30px; } #relief .form-control{ margin-top: 10px; margin-bottom: 10px; /*background-color: #FFCE42;*/ } .page{ margin-right: 10px; margin-bottom: 20px; } .table th { color: #C4C4C4; } .table tbody tr td+td+td { color: #D3964F; } </style> <script type="text/javascript"> function lastMonth(){ todo('last'); } function nextMonth(){ todo('next'); } function selectUser(){ todo('selectuser'); } function todo(type){ var s_year = $('#s_year').val(); var s_month = $('#s_month').val(); var s_user_id = $('#s_user_id').val(); window.location.href="{sh::U('User/trade')}&s_year="+s_year+"&s_month="+s_month+"&s_user_id="+s_user_id+"&type="+type; } </script> <body> <p data-example-id="list-group-btns" class="bs-example"> <p id="select-date"> <ul class="pager"> <li class="previous"><a onclick="lastMonth();"><span aria-hidden="true">←</span> </a></li> <span class="date-txt"><strong>{sh:$s_year}.{sh:$s_month}</strong> <present name="paymentData"><span class="glyphicon glyphicon-ok-sign" aria-hidden="true"></span></present> </span> <input type="text" id="s_year" value="{sh:$s_year}" hidden="hidden"> <input type="text" id="s_month" value="{sh:$s_month}" hidden="hidden"> <li class="next"><a onclick="nextMonth();"><span aria-hidden="true">→</span></a></li> </ul> </p> <p id="relief"> <select id="s_user_id" onchange="selectUser();" class="form-control btn-success"> <option value="">全部商户</option> <volist name="user_list" id="vo"> <option value="{sh:$vo.id}" <eq name="vo.id" value="$s_user_id">selected="selected"</eq>>{sh:$vo.username}</option> </volist> </select> </p> <p id="total" class="img-circle"> <p class="text-center money-txt"> <h3 id="总交易金额">总交易金额</h3> <h2 id="sh-totalprice">¥{sh:$totalprice}</h2> </p> </p> <p id="datalist"> <table class="table table-striped"> <thead> <tr> <th>商户</th> <th>日期</th> <th>交易金额</th> <!-- <th>状态</th> --> </tr> </thead> <tbody> <empty name="list"><tr><td class="text-center" colspan="4">暂无数据</td></tr></empty> <volist name="list" id="vo"> <tr> <td>{sh:$vo.username}</td> <td>{sh:$vo.paytime|date="Y-m-d H:i",###}</td> <td>{sh:$vo.price}</td> <!-- <td> <if condition="$vo.progress eq 1"><span class="text-primary">待发货</span> <elseif condition="$vo.progress eq 2"/><span class="text-danger">待签收</span> <elseif condition="$vo.progress eq 3"/><span class="text-success"><strong>已完成</strong></span> </if> </td> --> </tr> </volist> </tbody> </table> <p class="page text-right"> {sh:$page} </p> </p> </body> </html>
효과, 다른 사람의 디자인을 보고 자세히 알아보세요. 가장 중요한 것은 인터페이스 디스플레이입니다. 모든 데이터는 여러 디스플레이를 기반으로 하므로 먼저 어떤 데이터인지 확인하세요. 필요해서 얻으세요.
관련 추천:
위 내용은 thinkPHP 거래내역 조회 기능의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

PHP는 동적 웹 개발 및 서버 측 응용 프로그램에 사용되는 서버 측 스크립팅 언어입니다. 1.PHP는 편집이 필요하지 않으며 빠른 발전에 적합한 해석 된 언어입니다. 2. PHP 코드는 HTML에 포함되어 웹 페이지를 쉽게 개발할 수 있습니다. 3. PHP는 서버 측 로직을 처리하고 HTML 출력을 생성하며 사용자 상호 작용 및 데이터 처리를 지원합니다. 4. PHP는 데이터베이스와 상호 작용하고 프로세스 양식 제출 및 서버 측 작업을 실행할 수 있습니다.

PHP는 지난 수십 년 동안 네트워크를 형성했으며 웹 개발에서 계속 중요한 역할을 할 것입니다. 1) PHP는 1994 년에 시작되었으며 MySQL과의 원활한 통합으로 인해 개발자에게 최초의 선택이되었습니다. 2) 핵심 기능에는 동적 컨텐츠 생성 및 데이터베이스와의 통합이 포함되며 웹 사이트를 실시간으로 업데이트하고 맞춤형 방식으로 표시 할 수 있습니다. 3) PHP의 광범위한 응용 및 생태계는 장기적인 영향을 미쳤지 만 버전 업데이트 및 보안 문제에 직면 해 있습니다. 4) PHP7의 출시와 같은 최근 몇 년간의 성능 향상을 통해 현대 언어와 경쟁 할 수 있습니다. 5) 앞으로 PHP는 컨테이너화 및 마이크로 서비스와 같은 새로운 도전을 다루어야하지만 유연성과 활발한 커뮤니티로 인해 적응력이 있습니다.

PHP의 핵심 이점에는 학습 용이성, 강력한 웹 개발 지원, 풍부한 라이브러리 및 프레임 워크, 고성능 및 확장 성, 크로스 플랫폼 호환성 및 비용 효율성이 포함됩니다. 1) 배우고 사용하기 쉽고 초보자에게 적합합니다. 2) 웹 서버와 우수한 통합 및 여러 데이터베이스를 지원합니다. 3) Laravel과 같은 강력한 프레임 워크가 있습니다. 4) 최적화를 통해 고성능을 달성 할 수 있습니다. 5) 여러 운영 체제 지원; 6) 개발 비용을 줄이기위한 오픈 소스.

PHP는 죽지 않았습니다. 1) PHP 커뮤니티는 성능 및 보안 문제를 적극적으로 해결하고 PHP7.x는 성능을 향상시킵니다. 2) PHP는 최신 웹 개발에 적합하며 대규모 웹 사이트에서 널리 사용됩니다. 3) PHP는 배우기 쉽고 서버가 잘 수행되지만 유형 시스템은 정적 언어만큼 엄격하지 않습니다. 4) PHP는 컨텐츠 관리 및 전자 상거래 분야에서 여전히 중요하며 생태계는 계속 발전하고 있습니다. 5) Opcache 및 APC를 통해 성능을 최적화하고 OOP 및 설계 패턴을 사용하여 코드 품질을 향상시킵니다.

PHP와 Python에는 고유 한 장점과 단점이 있으며 선택은 프로젝트 요구 사항에 따라 다릅니다. 1) PHP는 웹 개발, 배우기 쉽고 풍부한 커뮤니티 리소스에 적합하지만 구문은 현대적이지 않으며 성능과 보안에주의를 기울여야합니다. 2) Python은 간결한 구문과 배우기 쉬운 데이터 과학 및 기계 학습에 적합하지만 실행 속도 및 메모리 관리에는 병목 현상이 있습니다.

PHP는 동적 웹 사이트를 구축하는 데 사용되며 해당 핵심 기능에는 다음이 포함됩니다. 1. 데이터베이스와 연결하여 동적 컨텐츠를 생성하고 웹 페이지를 실시간으로 생성합니다. 2. 사용자 상호 작용 및 양식 제출을 처리하고 입력을 확인하고 작업에 응답합니다. 3. 개인화 된 경험을 제공하기 위해 세션 및 사용자 인증을 관리합니다. 4. 성능을 최적화하고 모범 사례를 따라 웹 사이트 효율성 및 보안을 개선하십시오.

PHP는 MySQLI 및 PDO 확장 기능을 사용하여 데이터베이스 작업 및 서버 측 로직 프로세싱에서 상호 작용하고 세션 관리와 같은 기능을 통해 서버 측로 로직을 처리합니다. 1) MySQLI 또는 PDO를 사용하여 데이터베이스에 연결하고 SQL 쿼리를 실행하십시오. 2) 세션 관리 및 기타 기능을 통해 HTTP 요청 및 사용자 상태를 처리합니다. 3) 트랜잭션을 사용하여 데이터베이스 작업의 원자력을 보장하십시오. 4) SQL 주입 방지, 디버깅을 위해 예외 처리 및 폐쇄 연결을 사용하십시오. 5) 인덱싱 및 캐시를 통해 성능을 최적화하고, 읽을 수있는 코드를 작성하고, 오류 처리를 수행하십시오.

PHP에서 전처리 문과 PDO를 사용하면 SQL 주입 공격을 효과적으로 방지 할 수 있습니다. 1) PDO를 사용하여 데이터베이스에 연결하고 오류 모드를 설정하십시오. 2) 준비 방법을 통해 전처리 명세서를 작성하고 자리 표시자를 사용하여 데이터를 전달하고 방법을 실행하십시오. 3) 쿼리 결과를 처리하고 코드의 보안 및 성능을 보장합니다.


핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

AI Hentai Generator
AI Hentai를 무료로 생성하십시오.

인기 기사

뜨거운 도구

VSCode Windows 64비트 다운로드
Microsoft에서 출시한 강력한 무료 IDE 편집기

DVWA
DVWA(Damn Vulnerable Web App)는 매우 취약한 PHP/MySQL 웹 애플리케이션입니다. 주요 목표는 보안 전문가가 법적 환경에서 자신의 기술과 도구를 테스트하고, 웹 개발자가 웹 응용 프로그램 보안 프로세스를 더 잘 이해할 수 있도록 돕고, 교사/학생이 교실 환경 웹 응용 프로그램에서 가르치고 배울 수 있도록 돕는 것입니다. 보안. DVWA의 목표는 다양한 난이도의 간단하고 간단한 인터페이스를 통해 가장 일반적인 웹 취약점 중 일부를 연습하는 것입니다. 이 소프트웨어는

SublimeText3 Linux 새 버전
SublimeText3 Linux 최신 버전

드림위버 CS6
시각적 웹 개발 도구

맨티스BT
Mantis는 제품 결함 추적을 돕기 위해 설계된 배포하기 쉬운 웹 기반 결함 추적 도구입니다. PHP, MySQL 및 웹 서버가 필요합니다. 데모 및 호스팅 서비스를 확인해 보세요.
