这是技术胖讲的时候的
let sql = 'SELECT article.id as id,'+
'article.title as title,'+
'article.introduce as introduce,'+
'article.article_content as article_content,'+
"FROM_UNIXTIME(article.addTime,'%Y-%m-%d %H:%i:%s' ) as addTime,"+
'article.view_count as view_count ,'+
'type.typeName as typeName ,'+
'type.id as typeId '+
'FROM article LEFT JOIN type ON article.type_id = type.Id '+
'WHERE article.id='+id
但我发现我现在跟着做这样并不行,会报错,改成下面这样就可以了,用es6语法可以实现多行,但直接${id}还是会报错,因为这样是直接插入字符串,所以就照着别人的修改方法修改了一下就可以了
let sql = `SELECT article.id as id,
article.title as title,
article.introduce as introduce,
article.article_content as article_content,
FROM_UNIXTIME(article.addTime,'%Y-%m-%d %H:%i:%s' ) as addTime,
article.view_count as view_count ,
type.typeName as typeName ,
type.id as typeId
FROM article LEFT JOIN type ON article.type_id = type.Id
WHERE article.id="${id}"`