简体   繁体   中英

node mysql2 Incorrect arguments statement

this is my function. If I remove the ? and enter the info manually it executes, I would assume this is how you pass in parameters. is this correct? If i console log the params they all work, I am assuming the way the params are been passed down

async function getMultiple(page = 1){
    const offset = helper.getOffset(page, config.listPerPage);
    const rows = await db.query(
        'SELECT id, quote, author FROM quote LIMIT ?,?',
        [offset, config.listPerPage]
    );
    const data = helper.emptyOrRows(rows);
    const meta = {page};

    return {
        data,
        meta
    }
}

module.exports = {
  getMultiple
}

So it turns out that the mysql version I had installed (8.0.23) has a problem with prepared statements (or a different way). I had to downgrade to less than that and it worked as expected. I downgraded to 5.7

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM