|
本帖最后由 lx2118 于 2016-9-7 13:12 编辑
我在baas的private sql字段写了以下语句:SELECT fBuild FROM view_build WHERE fVillage=:village ORDER BY fBuild ASC
在前端页面使用以下代码调用相应的baas:
Model.prototype.baasData3BeforeRefresh = function(event){
var param123 = this.getElementByXid("select1234").value;
debugger;
var data = event.source;
if(param123!==""){
data.filters.setVar("village", param123);
}
};
我跟踪代码执行到了service.m文件编译后形成的do.java文件,在public static JSONObject queryBuild{}的第一句打上了断点,发现params中没有传入参数village。其params的参数值为:
{request=org.apache.catalina.connector.RequestFacade@19553d9, offset=0, columns={"fBuild":{"name":"fBuild","type":"String"},"fVillage":{"name":"fVillage","type":"String"}}, response=org.apache.catalina.connector.ResponseFacade@11edfc2, limit=20, tableName=view_build}
对比跟踪示例代码/demo/baas/complex,其使用的demo.service.m的queryUser方法中,sql字段的写法是:
SELECT u.fID, u.fName,
u.fPhoneNumber, u.fAddress, COUNT(ord.fID) AS orderCount FROM
takeout_user u LEFT JOIN takeout_order ord ON u.fID = ord.fUserID
WHERE (0=:useSearch) or (u.fID LIKE :search OR u.fName LIKE :search
OR u.fPhoneNumber LIKE :search OR u.fAddress LIKE :search) GROUP BY
u.fID, u.fName, u.fPhoneNumber, u.fAddress
前端调用代码为:
Model.prototype.userDataBeforeRefresh = function(event){
var searchVal = this.getElementByXid("searchInput").value;
var data = event.source;
debugger;
data.filters.setVar("search",'%'+searchVal+'%');
data.filters.setVar("useSearch",searchVal?1:0);
};
发现到了.m语句编译成的do.java的queryUser方法中,参数传递就在params中,params的参数值为:
{request=org.apache.catalina.connector.RequestFacade@19553d9, variables={"search":"%153%","useSearch":1}, offset=0, columns={"fAddress":{"name":"fAddress","type":"String"},"fID":{"name":"fID","type":"String"},"fName":{"name":"fName","type":"String"},"fPhoneNumber":{"name":"fPhoneNumber","type":"String"},"orderCount":{"name":"orderCount","type":"Integer"}}, response=org.apache.catalina.connector.ResponseFacade@11edfc2, limit=5, tableName=takeout_user}
可以看到参数在variables={"search":"%153%","useSearch":1}
请问这是怎么回事?谢谢!
另外,data.filters.setVar方法好像在代码提示中不存在,我的代码提示如下所示:请问是怎么回事?
|
-
|