<code>SELECT `app_plan`.*, `app_agreement`.*, `app_customer`.*, `app_product`.*, `app_product_category`.*, @计划总原发量:=( select sum(`app_operation`.`send_weight`) from `app_operation` where `app_operation`.`plan_id`= `app_plan`.`plan_id` AND `app_operation`.`is_del`= 0) as `plan_total_send_weight`, @计划总实收量:=( select sum(`app_operation`.`receive_weight`) from `app_operation` where `app_operation`.`plan_id`= `app_plan`.`plan_id` AND `app_operation`.`is_del`= 0) as `plan_total_receive_weight`, @计划总路损量:= IFNULL(( select sum(`app_operation`.`send_weight`-`app_operation`.`receive_weight`) from `app_operation` where `app_operation`.`plan_id`= `app_plan`.`plan_id` AND `app_operation`.`is_del`= 0 AND `app_operation`.`operation_status`= 2), 0) as `plan_total_lost_quantity`, @计划总在途量:= IFNULL(( select sum(`app_operation`.`send_weight`) from `app_operation` where `app_operation`.`plan_id`= `app_plan`.`plan_id` AND `app_operation`.`is_del`= 0 AND `app_operation`.`operation_status`= 1), 0) as `plan_onway_quantity`, @计划路损超出量:= IFNULL(( SELECT sum(`app_operation`.`send_weight`-`app_operation`.`receive_weight`- `app_plan`.`rational_loss`) from `app_operation` where `app_operation`.`plan_id`= `app_plan`.`plan_id` and `app_operation`.`is_del`= 0 AND `app_operation`.`operation_status`= 2 AND(`send_weight`-`receive_weight`)> `app_plan`.`rational_loss`), 0) AS plan_over_lost, @路损超出扣款:= truncate(IFNULL(( SELECT sum((`app_operation`.`send_weight`-`app_operation`.`receive_weight`- `app_plan`.`rational_loss`) * `app_plan`.`plan_deduct_fee`) from `app_operation` where `app_operation`.`plan_id`= `app_plan`.`plan_id` and `app_operation`.`is_del`= 0 AND `app_operation`.`operation_status`= 2 AND(`send_weight`-`receive_weight`)> `app_plan`.`rational_loss`), 0), 2) AS plan_total_punish_fee, @计划总发车数:= IFNULL(( select count(*) from `app_operation` where `app_operation`.`plan_id`= `app_plan`.`plan_id` AND `app_operation`.`is_del`= 0), 0) as `plan_count_send`, @计划总收车数:= IFNULL(( select count(*) from `app_operation` where `app_operation`.`plan_id`= `app_plan`.`plan_id` AND `app_operation`.`operation_status`= 2 AND `app_operation`.`is_del`= 0), 0) as `plan_count_receive`, @总运费:= truncate(IFNULL(( SELECT sum(`app_operation`.`receive_weight` * `app_operation`.`operation_fee`) FROM `app_operation` WHERE `app_operation`.plan_id= `app_plan`.`plan_id` AND `app_operation`.`is_del`= 0), 0), 2) as `plan_total_ship_fee`, @应付运费:= truncate(IFNULL((@总运费 - @路损超出扣款), 0), 2) AS total_invoice_ship_fee, @计划未发量:= truncate(IFNULL(`plan_total_quantity` - @计划总实收量 - @计划总在途量, 0), 2) AS `plan_total_not_quantity` FROM(`app_plan`) LEFT JOIN `app_agreement` ON `app_plan`.`agreement_id`= `app_agreement`.`agreement_id` LEFT JOIN `app_customer` ON `app_agreement`.`customer_id`= `app_customer`.`customer_id` LEFT JOIN `app_product` ON `app_agreement`.`product_id`= `app_product`.`product_id` LEFT JOIN `app_product_category` ON `app_product`.`category_id`= `app_product_category`.`category_id` WHERE `plan_status`= 1 AND `app_plan`.`is_del`= 0</code>
附件是数据库SQL备份。
大家尝试看看,这应该算相当复杂的SQL了吧。
客户端的运行结果
数据库备份下载地址:http://7xiqxd.com2.z0.glb.qiniucdn.com/deliver.sql.zip
回复内容:
<code>SELECT `app_plan`.*, `app_agreement`.*, `app_customer`.*, `app_product`.*, `app_product_category`.*, @计划总原发量:=( select sum(`app_operation`.`send_weight`) from `app_operation` where `app_operation`.`plan_id`= `app_plan`.`plan_id` AND `app_operation`.`is_del`= 0) as `plan_total_send_weight`, @计划总实收量:=( select sum(`app_operation`.`receive_weight`) from `app_operation` where `app_operation`.`plan_id`= `app_plan`.`plan_id` AND `app_operation`.`is_del`= 0) as `plan_total_receive_weight`, @计划总路损量:= IFNULL(( select sum(`app_operation`.`send_weight`-`app_operation`.`receive_weight`) from `app_operation` where `app_operation`.`plan_id`= `app_plan`.`plan_id` AND `app_operation`.`is_del`= 0 AND `app_operation`.`operation_status`= 2), 0) as `plan_total_lost_quantity`, @计划总在途量:= IFNULL(( select sum(`app_operation`.`send_weight`) from `app_operation` where `app_operation`.`plan_id`= `app_plan`.`plan_id` AND `app_operation`.`is_del`= 0 AND `app_operation`.`operation_status`= 1), 0) as `plan_onway_quantity`, @计划路损超出量:= IFNULL(( SELECT sum(`app_operation`.`send_weight`-`app_operation`.`receive_weight`- `app_plan`.`rational_loss`) from `app_operation` where `app_operation`.`plan_id`= `app_plan`.`plan_id` and `app_operation`.`is_del`= 0 AND `app_operation`.`operation_status`= 2 AND(`send_weight`-`receive_weight`)> `app_plan`.`rational_loss`), 0) AS plan_over_lost, @路损超出扣款:= truncate(IFNULL(( SELECT sum((`app_operation`.`send_weight`-`app_operation`.`receive_weight`- `app_plan`.`rational_loss`) * `app_plan`.`plan_deduct_fee`) from `app_operation` where `app_operation`.`plan_id`= `app_plan`.`plan_id` and `app_operation`.`is_del`= 0 AND `app_operation`.`operation_status`= 2 AND(`send_weight`-`receive_weight`)> `app_plan`.`rational_loss`), 0), 2) AS plan_total_punish_fee, @计划总发车数:= IFNULL(( select count(*) from `app_operation` where `app_operation`.`plan_id`= `app_plan`.`plan_id` AND `app_operation`.`is_del`= 0), 0) as `plan_count_send`, @计划总收车数:= IFNULL(( select count(*) from `app_operation` where `app_operation`.`plan_id`= `app_plan`.`plan_id` AND `app_operation`.`operation_status`= 2 AND `app_operation`.`is_del`= 0), 0) as `plan_count_receive`, @总运费:= truncate(IFNULL(( SELECT sum(`app_operation`.`receive_weight` * `app_operation`.`operation_fee`) FROM `app_operation` WHERE `app_operation`.plan_id= `app_plan`.`plan_id` AND `app_operation`.`is_del`= 0), 0), 2) as `plan_total_ship_fee`, @应付运费:= truncate(IFNULL((@总运费 - @路损超出扣款), 0), 2) AS total_invoice_ship_fee, @计划未发量:= truncate(IFNULL(`plan_total_quantity` - @计划总实收量 - @计划总在途量, 0), 2) AS `plan_total_not_quantity` FROM(`app_plan`) LEFT JOIN `app_agreement` ON `app_plan`.`agreement_id`= `app_agreement`.`agreement_id` LEFT JOIN `app_customer` ON `app_agreement`.`customer_id`= `app_customer`.`customer_id` LEFT JOIN `app_product` ON `app_agreement`.`product_id`= `app_product`.`product_id` LEFT JOIN `app_product_category` ON `app_product`.`category_id`= `app_product_category`.`category_id` WHERE `plan_status`= 1 AND `app_plan`.`is_del`= 0</code>
附件是数据库SQL备份。
大家尝试看看,这应该算相当复杂的SQL了吧。
客户端的运行结果
数据库备份下载地址:http://7xiqxd.com2.z0.glb.qiniucdn.com/deliver.sql.zip
这么复杂干嘛还非要用链式来解决呢,你的SQL都出来了,直接SQL不就行了么。TP的Model只是为了方便使用,封装了常用的几种简单查询更新的操作,复杂的操作建议直接SQL实现。就算你绞尽脑汁想出了一个复杂的通过TP链式方法实现这个复杂操作的写法,最后TP还是要把你的操作转成SQL,你说你这不是瞎费劲么?
这么复杂的sql语句不建议转换成TP的sql语句,没有什么太大的意义。TP的链式方式最终还是会转义成sql语句来实现的,可以先写好sql,对然后用M对数据库实例化执行sql就可以了。还有如此复杂的sql中存在内外链接,这样会很大的消耗sql资源,如果数据量大的情况下,获取数据不易,建议拆分sql语句,获得基础数据后用php语言写算法,这样速度会快一些。
你要效能還是想要語句結構化?
要效能就直接SQL算出來
要語句理解就用Model完成邏輯

phpidifiesauser의 sssessionusessessioncookiesandssessionids.1) whensession_start () iscalled, phpgeneratesauniquessessionStoredInacookienamedPhpsSessIdonSeuser 'sbrowser.2) thisidallowsphptoretrievessessionDataTromServer.

PHP 세션의 보안은 다음 측정을 통해 달성 할 수 있습니다. 1. Session_REGENEREAT_ID ()를 사용하여 사용자가 로그인하거나 중요한 작업 일 때 세션 ID를 재생합니다. 2. HTTPS 프로토콜을 통해 전송 세션 ID를 암호화합니다. 3. 세션 _save_path ()를 사용하여 세션 데이터를 저장하고 권한을 올바르게 설정할 보안 디렉토리를 지정하십시오.

phpsessionfilesarestoredInTheRectorySpecifiedBysession.save_path, 일반적으로/tmponunix-likesystemsorc : \ windows \ temponwindows.tocustomizethis : 1) austession_save_path () toSetacustomDirectory, verlyTeCustory-swritation;

toretrievedatafromAphPsession, startSessionstart_start () andaccessvariblesinthe $ _sessionArray.forexample : 1) startthessession : session_start (). 2) retrievedata : $ _ session [ 'username']; echo "Welcome,". $ username;

세션을 사용하여 효율적인 쇼핑 카트 시스템을 구축하는 단계에는 다음이 포함됩니다. 1) 세션의 정의와 기능을 이해합니다. 세션은 요청에 따라 사용자 상태를 유지하는 데 사용되는 서버 측 스토리지 메커니즘입니다. 2) 쇼핑 카트에 제품 추가와 같은 기본 세션 관리를 구현합니다. 3) 제품 수량 관리 및 삭제 지원 고급 사용으로 확장; 4) 세션 데이터를 지속하고 보안 세션 식별자를 사용하여 성능 및 보안을 최적화합니다.

이 기사는 PHP의 인터페이스를 생성, 구현 및 사용하는 방법을 설명하여 코드 구성 및 유지 관리에 대한 이점에 중점을 둡니다.

이 기사에서는 PHP의 암호 해싱에 대한 Crypt ()와 Password_hash ()의 차이점에 대해 논의하여 최신 웹 애플리케이션에 대한 구현, 보안 및 적합성에 중점을 둡니다.

기사는 입력 유효성 검사, 출력 인코딩 및 OWASP ESAPI 및 HTML 청정기와 같은 도구를 통해 PHP의 크로스 사이트 스크립팅 (XSS) 방지에 대해 논의합니다.


핫 AI 도구

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

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

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

Clothoff.io
AI 옷 제거제

Video Face Swap
완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

인기 기사

뜨거운 도구

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

안전한 시험 브라우저
안전한 시험 브라우저는 온라인 시험을 안전하게 치르기 위한 보안 브라우저 환경입니다. 이 소프트웨어는 모든 컴퓨터를 안전한 워크스테이션으로 바꿔줍니다. 이는 모든 유틸리티에 대한 액세스를 제어하고 학생들이 승인되지 않은 리소스를 사용하는 것을 방지합니다.

SublimeText3 Linux 새 버전
SublimeText3 Linux 최신 버전

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

PhpStorm 맥 버전
최신(2018.2.1) 전문 PHP 통합 개발 도구
