我正在使用sqlite3适配器来获取Ruby并获得一些奇怪的行为。我正在使用?
来逃避对我的查询的输入。以下作品:
db.execute 'SELECT * FROM table_name WHERE id = ?', 1
=> [{ "id"=> 1, "name" => "Hannah" }]
db.execute 'SELECT * FROM table_name WHERE name = ?, 'Hannah'
=> [{ "id"=> 1, "name" => "Hannah" }]
db.execute 'SELECT * FROM table_name WHERE id = 1 AND name = ?', 'Hannah'
=> [{ "id"=> 1, "name" => "Hannah" }]
但是,以下内容不起作用:
db.execute 'SELECT * FROM table_name WHERE id = ? AND name = ?', 1, 'Hannah'
=> []
为什么会这样?