| Class | Sequel::MySQL::Dataset |
| In: |
lib/sequel_core/adapters/mysql.rb
|
| Parent: | Sequel::Dataset |
MySQL is different in that it supports prepared statements but not bound variables outside of prepared statements. The default implementation breaks the use of subselects in prepared statements, so extend the temporary prepared statement that this creates with a module that fixes it.
# File lib/sequel_core/adapters/mysql.rb, line 261
261: def call(type, bind_arguments={}, values=nil)
262: ps = to_prepared_statement(type, values)
263: ps.extend(CallableStatementMethods)
264: ps.call(bind_arguments)
265: end
Delete rows matching this dataset
# File lib/sequel_core/adapters/mysql.rb, line 268
268: def delete(opts = nil)
269: execute_dui(delete_sql(opts)){|c| c.affected_rows}
270: end
Yield all rows matching this dataset
# File lib/sequel_core/adapters/mysql.rb, line 273
273: def fetch_rows(sql)
274: execute(sql) do |r|
275: column_types = []
276: @columns = r.fetch_fields.map{|f| column_types << f.type; output_identifier(f.name)}
277: while row = r.fetch_row
278: h = {}
279: @columns.each_with_index {|f, i| h[f] = convert_type(row[i], column_types[i])}
280: yield h
281: end
282: end
283: self
284: end
Insert a new value into this dataset
# File lib/sequel_core/adapters/mysql.rb, line 287
287: def insert(*values)
288: execute_dui(insert_sql(*values)){|c| c.insert_id}
289: end
Handle correct quoting of strings using ::MySQL.quote.
# File lib/sequel_core/adapters/mysql.rb, line 292
292: def literal(v)
293: case v
294: when LiteralString
295: v
296: when String
297: "'#{::Mysql.quote(v)}'"
298: else
299: super
300: end
301: end
Store the given type of prepared statement in the associated database with the given name.
# File lib/sequel_core/adapters/mysql.rb, line 305
305: def prepare(type, name=nil, values=nil)
306: ps = to_prepared_statement(type, values)
307: ps.extend(PreparedStatementMethods)
308: if name
309: ps.prepared_statement_name = name
310: db.prepared_statements[name] = ps
311: end
312: ps
313: end