如果我有此代码,如何将循环值放入数组?
local data = {
for row in db:nrows("SELECT song.id, song.title as title, artist.name as name FROM song, artist where song.artist_id = artist.id") do
{
song = row.title,
artist = row.name
}
end
}
但我收到了这个错误:
unexpected symbol near 'for'
我只是想看起来像这样...
local data = {
{
song = "HI",
artist = "Tom"
}
{
song = "Hello",
artist = "mike"
}
...
}
任何人都可以帮助我了解我的情况或提供一些建议吗?提前致谢