开发者

Broken query using MySQL module with Ruby?

Any idea what is broken about my query here?

irb(main):010:0> dbh.query('SELECT foo FROM bar')
Mysql::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"' at line 1
    from (irb):10:in `query'
    from (irb):10
    from /usr/bin/irb1.9:12:in `<main>'

the table bar definitely exists as does the column 开发者_如何学Gofoo.

also dbh is a legit object:

irb(main):012:0> dbh
=> #<Mysql:0x91149c4>

irb(main):011:0> dbh.methods.grep(/query/)
=> [:query, :real_query, :query_with_result, :query_with_result=]


Paste a real query, maybe table name or field name is a reserved keyword in mysql.

Try using delimiters:

dbh.query('SELECT `foo` FROM `bar`')
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜