2017-05-30 44 views
1

我希望能够使用变量构建SQL查询。查询中的变量 - 服务器端脚本

如何在Google App Maker服务器端脚本中创建此PHP语句的等效项?

$query = "SELECT * FROM table WHERE orderId = $orderNo"; 

- (“$ orderNo”作为一个变量)

这可以通过计算模型来实现,如果是的话,我需要了解如何计算的SQL查询中使用变量。

像这样:https://developers.google.com/appmaker/models/cloudsql#sql_calculated_model

这里的变量最终需要在页面上的ID属性。

完全不同的方法是受欢迎的

非常感谢。

回答

1

您可以使用数据源查询生成器(https://developers.google.com/appmaker/models/datasources#query_builder): enter image description here

或入侵 '其中' 查询属性(服务器脚本):

var newQuery = app.models.Company.newQuery(); 

newQuery.where = 'Name contains? :SearchText or Address contains? :SearchText or Website contains? :SearchText'; 
newQuery.parameters.SearchText = 'search term'; 
companies = newQuery.run() 

你可以找到例子模板(https://developers.google.com/appmaker/templates/)。 Q &论坛(查询生成器),合作伙伴管理(如何使用'where'查询属性)。

+0

谢谢先生!这导致我的解决方案! –

+0

你是受欢迎的! –