天翎MyApps技术社区 - 低代码平台 | 流程管理系统 | BPM软件

 找回密码
 注册成为天翎用户
查看: 1786|回复: 0

[函数] 视图查询【函数-getWhereSQL (itemNames, conditions, fieldNames)】

[复制链接]
purple 发表于 2011-11-29 10:59:56 | 显示全部楼层 |阅读模式
本帖最后由 purple 于 2012-12-31 13:44 编辑

函数格式:
getWhereSQL (itemNames, conditions, fieldNames)
函数说明:
tableName :一般传查询表单的字段用[]扩住
conditions :查询方式 “like”“=”
fieldNames : 对应数据库里要查询的字段名 item_xxx
示例:
实现getWhereSQL(itemNames,conditions,fieldNames)函数的应用
function getWhereSQL(itemNames,conditions,fieldNames){
        var sqlWhere = "";
        for (var i = 0; i < itemNames.length; i++) {
                var itemValue = getItemValue(itemNames);
                if (itemValue != null && itemValue.trim().length() > 0) {
                        if (conditions == "like") itemValue = "%" + itemValue + "%";
                        var item = fieldNames;
                        //for Oracle
                        if (conditions == "<=" || conditions == ">=") {
                                item = "to_char(" + item + ",'yyyy-MM-dd')";
                        }
                        sqlWhere += " and " + item + " " + conditions + " '" + itemValue + "'";
                }
        }
        return sqlWhere;
}

调用
#include " autosqllib";
getWhereSQL ("itemNames", " conditions","fieldNames");

本版积分规则

QQ|手机版|天翎MyApps技术社区 ( 粤ICP备11093750号 )

GMT+8, 2026-8-12 05:52

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表