使用yii\rest\ActiveController
没有pagelimit
这就是我在做的事情
<?php
namespace rest\modules\v1\controllers;
use yii\rest\ActiveController;
class CompanyController extends ActiveController
{
public $modelClass = 'frontend\models\TblDeliveredCompanies';
}
以上仅返回20条记录,如何改进它以返回所有
答案 0 :(得分:2)
您可以覆盖控制器内的prepareDataProvider()以从索引操作返回自定义数据提供程序:
SELECT A.ID,
B.NAME,
A.NAME AS TNAME
FROM TREEMATCHING A
INNER JOIN MATCHING B ON A.NAME LIKE B.NAME+'%'
ID NAME TNAME
----------- -------------------- --------------------
1 Child Child-Foster
2 Child Child-Filly
3 Child Child-Ricky
4 GrandChild GRandchild-Filmy
5 GrandChild GRandchild-Freaky
6 GrandChild GRandchild-Frim
9 parent parent-John
查看http://www.yiiframework.com/doc-2.0/guide-rest-controllers.html#extending-active-controller
上的文档答案 1 :(得分:1)
20的限制可能与dataProvider的默认分页值有关,所以在你的控制器/动作或创建$ dataProvider的模型中你应该重新定义函数,将分页分配为false
Option Explicit
Const tbNames As String = "NBInv NEBInv EBInv SEBInv SBInv SWBInv WBInv NWBInv" '<--| list all your relevant XBInv textboxes names
Const shpXFlowNames As String = "NFlow NEFlow EFlow SEFlow SFlow SWFlow WFlow NWFlow" '<--| list all "XFlow" shapes names corresponding to each XBInv textboxe
Const shpFlowXFalseNames As String = "FlowNFalse FlowNEFalse FlowEFalse FlowSEFalse FlowSFalse FlowSWFalse FlowWFalse FlowNWFalse" '<--| list all "FlowXFalse" shapes names corresponding to each XBInv textboxe
Dim tbs As Variant, shpXFlows As Variant, shpFlowXFalses As Variant
Sub CheckTB()
Dim minVal As Long
Dim iShp As Long
Dim iTbMin As Long
tbs = Split(tbNames) '<--| fill the array with textboxes names
shpXFlows = Split(shpXFlowNames) '<--| fill the array with "XFlow" shapes names
shpFlowXFalses = Split(shpFlowXFalseNames) '<--| fill the array with "FlowXFalse" shapes names
minVal = GetMinVal(iTbMin)
For iShp = 0 To UBound(shpXFlows) '<--| loop through shapes to hide all "XFlow"s and unhide all "FlowXFalse"s
Shapes(shpXFlows(iShp)).Visible = False
Shapes(shpFlowXFalses(iShp)).Visible = True
Next
Shapes(shpXFlows(iTbMin)).Visible = True '<--| unhide "XFlow" shape with minimum value
Shapes(shpFlowXFalses(iTbMin)).Visible = False '<--| hide "FlowXFalse" shape with minimum value
End Sub
Function GetMinVal(iTbMin As Long) As Long
Dim iTb As Long
iTbMin = 0 '<--|initialize textbox index with minimum value to the first one
GetMinVal = OLEObjects(tbs(iTbMin)).Object.Value '<--|initialize textbox with minimum value to the first one
For iTb = 0 To UBound(tbs)
If CLng(OLEObjects(tbs(iTb)).Object.Value) < GetMinVal Then
GetMinVal = CLng(OLEObjects(tbs(iTb)).Object.Value)
iTbMin = iTb
End If
Next
End Function
Private Sub EBInv_Change()
CheckTB
End Sub
Private Sub NEBInv_Change()
CheckTB
End Sub
Private Sub NBInv_Change()
CheckTB
End Sub
Private Sub NWBInv_Change()
CheckTB
End Sub
Private Sub SBInv_Change()
CheckTB
End Sub
Private Sub SEBInv_Change()
CheckTB
End Sub
Private Sub SWBInv_Change()
CheckTB
End Sub
Private Sub WBInv_Change()
CheckTB
End Sub
或
$dataProvider->pagination = false;
答案 2 :(得分:0)
检查'TblDeliveredCompanies'
处的模型类'frontend\models\TblDeliveredCompanies'
中的代码,它必须包含包含限制20的SQL查询,将其更改为'SELECT * from yourtbl where %yourcond%'