优化以下代码exportsgetSelectBlogs = req res = const info = reqbody; const sqlStr = select from blogs_info where title LIKE ; dbquerysqlStr infotitle err results = if err return rescce
exports.getSelectBlogs = (req, res) => {
const info = req.body;
const title = %${info.title}%;
const sqlStr = `select * from blogs_info where title LIKE ?`;
db.query(sqlStr, title, (err, results) => {
if (err) return res.cc(err);
if (results.length === 0) return res.cc("查询文章失败,该文章不存在");
res.send({
status: 0,
message: "查询成功",
data: results
});
});
};
原文地址: https://www.cveoy.top/t/topic/h1Tx 著作权归作者所有。请勿转载和采集!