thinkphp5 1中使用閉包傳參

2021-10-05 04:04:09 字數 1187 閱讀 7990

在thinkphp5模型的查詢中,一般有兩種方式:陣列方式和閉包方式,相對於陣列方式只能定義查詢條件,閉包方式可以支援更多的連貫操作,包括排序、數量限制等。

那麼我們在使用閉包方式要怎麼傳入引數呢?具體**如下:

//非超級管理員與審核人,不能查考到

$user_id

=$_session

['fw'][

'admin_user'][

'id'];

// $this->_query($this->table_log)

db::table

($this

->

table_log)-

>

alias

('log')-

>

leftjoin

("$this

->

table

po",'log.pid=po.id')-

>

field

('po.order_no as order_no,po.create_time_auto as create_time_auto,po.producer_name as producer_name,po.purchasing_entity as purchasing_entity,po.scanning_copy as scanning_copy,log.is_result as is_result,po.audit_status as audit_status,po.is_signed as is_signed,log.id as log_id,po.id as po_id')-

>

where([

['log.is_result'

,'eq',0

]])-

>

where

(function

($query

)use

($user_id))

->

order

('po.create_time_auto desc')-

>

select()

;echo db:

:name

($this

->

table_log)-

>

getlastsql()

;die

;

ThinkPHP5 1中介軟體在控制器中使用過程

使用中介軟體的開始以及我的步驟描述,希望可以幫到才學php 或者才學think框架的你們希望能夠與你們交流,讓自己進步。中介軟體在thinkphp框架中的作用我已經明白了,就是在請求即將達到應用層之前,對使用者訪問資源時候,產生的header頭 或者 使用者的請求引數時候輸入的post 或get 或...

thinkphp5 1的安裝與初步使用

1.安裝composer 出現如上邊所示表示安裝成功此時建議在安裝中文映象執行如下命令 composer config g repo.packagist composer安裝好之後就進行專案安裝找到自己專案所在位址www資料夾目錄下邊 在終端將形目位址切換到www目錄下邊然後在 在上邊 上選擇自己所...

thinkphp5 1中介軟體

class check return next request 中介軟體的入口執行方法必須是 handle 方法,而且第乙個引數是 request 物件,第二個引數是乙個閉包,在一些情況下允許有第三個引數 在路由中直接註冊中介軟體 route get hello name index hello m...