当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript mysql.escape函数代码示例

本文整理汇总了TypeScript中mysql.escape函数的典型用法代码示例。如果您正苦于以下问题:TypeScript escape函数的具体用法?TypeScript escape怎么用?TypeScript escape使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了escape函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: createSelectSql

    createSelectSql(option: MariaDBBase.FindOption): string {

        let sql: string
            = "SELECT userId, mid, age, gender"
            + " FROM user"
            + " WHERE enable = TRUE";

        if (option.conditions) {
            for (const condition of option.conditions) {
                sql += " AND " + condition;
            }
        }

        sql += " ORDER BY userId";

        // LIMIT, OFFSETの付与
        if (option.limit) {
            sql += " LIMIT " + mysql.escape(option.offset);
            if (option.offset) {
                sql += " OFFSET " + mysql.escape(option.offset);
            }
        }
        sql += ";";

        return sql;

    }
开发者ID:Huruikagi,项目名称:Meshinator,代码行数:27,代码来源:UserMariaDBContainer.ts

示例2: createSelectSql

    protected createSelectSql(option: MariaDBBase.FindOption) {

        // 基本となるSQL
        let sql: string
            = "SELECT i.itemId, n.name"
            + " FROM item i, item_names n"
            + " WHERE i.enable = TRUE"
            + " AND i.itemId = n.itemId";

        if (option.conditions) {
            // WHEREで指定する条件の付加
            for (const condition of option.conditions) {
                sql += " AND " + condition;
            }
        }

        sql += " ORDER BY itemId";

        // LIMIT, OFFSETの付与
        if (option.limit) {
            sql += " LIMIT " + mysql.escape(option.offset);
            if (option.offset) {
                sql += " OFFSET " + mysql.escape(option.offset);
            }
        }
        sql += ";";

        // 生成されたSQLの返却
        return sql;
    }
开发者ID:Huruikagi,项目名称:Meshinator,代码行数:30,代码来源:ItemMariaDBContainer.ts

示例3: update

    update(log: RequestLog, option?: MariaDBBase.QueryOption): Promise<void> {

        let sql: string
            = "DELETE FROM meshinator_message"
            + " WHERE logId = " + log.id + "; "

            + "UPDATE request_log"
            + " SET date=" +  mysql.escape(log.date) + ","
            + " userMessage=" + mysql.escape(log.userMessage) + ","
            + " contextId=" + mysql.escape(log.contextId)
            + " WHERE logId = " + log.id + "; ";

        for (const mmNum in log.meshinatorMessages) {
            sql += "INSERT INTO meshinator_message(logId, num, message)"
                + " VALUES("
                + log.id + ", "
                + mmNum + ", "
                + mysql.escape(log.meshinatorMessages[mmNum])
                + "); ";
        }

        return this.executeUpdate(sql, option)
            .then(() => log.saved());

    }
开发者ID:Huruikagi,项目名称:Meshinator,代码行数:25,代码来源:RequestLogMariaDBContainer.ts

示例4: limitSql

 /**
  * FindOptionのlimitおよびoffsetプロパティが存在した場合に、
  * LIMIT句の条件分を生成するためのメソッド。
  *
  * MariaDBBaseの実装クラスにおいて、createSelectSql内で使用する。
  *
  * @param limit
  * @param offset
  * @returns {string}
  */
 protected limitSql(limit?: number, offset?: number): string {
     let sql: string = "";
     if (limit) {
         sql += " LIMIT " + mysql.escape(limit);
         if (offset) {
             sql += " OFFSET " + mysql.escape(offset);
         }
     }
     return sql;
 }
开发者ID:Huruikagi,项目名称:Meshinator,代码行数:20,代码来源:MariaDBBase.ts

示例5: updateSimpleQuery

export function updateSimpleQuery(TABLE:string,UpdateObj:any,addWhere:any,callback: (results:any) => void){
    var k , v ;
    var update=new Array();
    //mysql.escape will add '' !!
    for(k in UpdateObj)
    {
        update[update.length]="`"+k+"`=  "+mysql.escape(UpdateObj[k])+" ";
    }
    
    var where=new Array();
    var s;
    if((typeof addWhere =='object')&&(addWhere.hasOwnProperty('length')))
    {
        if(addWhere.length>0)
        {
            where=where.concat(addWhere);
        }
    }
    var wherestr=(where.length>0)?'  WHERE  '+where.join('  AND '):'';

    var sql="UPDATE `"+TABLE+"` SET "+update.join(",")+" "+wherestr;
    db.query(sql,function(err, results, fields){
        
        if(err)
        { console.error(err); console.error(sql);  return; }

        if(typeof callback==="function")
        {
            callback(results);
        }
    });
}
开发者ID:michsu0927,项目名称:node-mysql-demo,代码行数:32,代码来源:db.ts

示例6: insertSimpleQuery

export function insertSimpleQuery(TABLE:string,InserObj:any,callback: (results:any) => void){
    var k , v;
    var fieldarr=new Array();
    var valuearr=new Array();
    //console.log(InserObj);
    for( k in InserObj)
    {
        fieldarr[fieldarr.length]=k;
        //mysql.escape will add '' !!
        valuearr[valuearr.length]=mysql.escape(InserObj[k]);
    }
    //console.log(valuearr);
    var sql="INSERT INTO `"+TABLE+"` (`"+fieldarr.join("`,`")+"`) VALUES ( "+valuearr.join(",")+" ) ";
    //console.log( sql );
    db.query(sql,function(err, results, fields){
        
        if(err)
        { console.error(err); console.error(sql);  return; }

        if(typeof callback==="function")
        {
            callback(results);
        }
    });
}
开发者ID:michsu0927,项目名称:node-mysql-demo,代码行数:25,代码来源:db.ts

示例7: getWhile

    getWhile(start: Date, end: Date, limit?: number, offset?: number, option?: MariaDBBase.QueryOption): Promise<RequestLog[]> {

        if (!option) option = {commit: true};

        const whileConditions: string[] = [
            "l.date >= " + mysql.escape(start),
            "l.date <= " + mysql.escape(end)
        ];

        return this.find({
            transaction: option.transaction,
            commit: option.commit,
            limit: limit,
            offset: offset,
            conditions: whileConditions
        });
    }
开发者ID:Huruikagi,项目名称:Meshinator,代码行数:17,代码来源:RequestLogMariaDBContainer.ts

示例8: insert

    insert(user: User, option?: MariaDBBase.QueryOption): Promise<void> {

        const mid: string = mysql.escape(user.mid);
        const age: string = mysql.escape(user.age);
        const gender: string = mysql.escape(user.gender.id);

        const sql: string
            = "INSERT INTO user(mid, age, gender)"
            + " VALUES (" + mid + ", " + age + ", " + gender + ");";

        return this.query(sql, option)
            .then(result => {
                user.defineId(result["insertId"]);
                user.saved();
            });

    }
开发者ID:Huruikagi,项目名称:Meshinator,代码行数:17,代码来源:UserMariaDBContainer.ts

示例9: update

    update(user: User, option?: MariaDBBase.QueryOption): Promise<void> {

        const id: string = mysql.escape(user.id);
        const mid: string = mysql.escape(user.mid);
        const age: string = mysql.escape(user.age);
        const gender: string = mysql.escape(user.gender.id);

        const sql: string
            = "UPDATE user SET"
            + " mid=" + mid + ","
            + " age=" + age + ","
            + " gender=" + gender
            + " WHERE userId = " + id + ";";

        return this.executeUpdate(sql, option)
            .then(() => user.saved());

    }
开发者ID:Huruikagi,项目名称:Meshinator,代码行数:18,代码来源:UserMariaDBContainer.ts

示例10: remove

    remove(user: User, option?: MariaDBBase.QueryOption): Promise<void> {

        const sql: string
            = "UPDATE user SET enable = FALSE"
            + " WHERE userId = " + mysql.escape(user.id) + ";";

        return this.executeUpdate(sql, option);

    }
开发者ID:Huruikagi,项目名称:Meshinator,代码行数:9,代码来源:UserMariaDBContainer.ts


注:本文中的mysql.escape函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。