最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

无法在 Nodejs 中使用参数化查询

网站源码admin39浏览0评论

无法在 Nodejs 中使用参数化查询

无法在 Nodejs 中使用参数化查询

我正在使用 Nodejs/expressjs,现在我很想执行参数化查询,但是我在 console.log 中收到以下错误,我该如何解决这个问题?

SyntaxError: Missing initializer in destructuring declaration

这是我的代码

[![static async addServiceDetail(shopId,serviceId,genderTypeId,price,serviceName)
    {
        const sql = `SELECT id from hc_servicesdetail WHERE shopId='${shopId}' AND  serviceId='${serviceId}' AND genderTypeId='genderTypeId'`;
        const \[rows, fields\] = await pool.execute(sql);
        if(rows<1)
            {
                const sql2 = `INSERT INTO servicesdetail (userId, serviceId, genderTypeId,price,serviceName) VALUES (?, ?,  ?, ?, ?)`,\[userId, serviceId, genderTypeId, price, serviceName\]`;
                console.log('query is '+ sql);
                const \[datass, _\] = await pool.execute(sql2);
                console.log('last inserted id is ' +datass.insertId);
            }
        else
            {
                console.log('already exist');
            }   
    }
}][1]][1]
回答如下:
发布评论

评论列表(0)

  1. 暂无评论