當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。