Class | Sequel::MySQL::Dataset |
In: |
lib/sequel/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/adapters/mysql.rb, line 293 293: def call(type, bind_arguments={}, values=nil) 294: ps = to_prepared_statement(type, values) 295: ps.extend(CallableStatementMethods) 296: ps.call(bind_arguments) 297: end
Delete rows matching this dataset
# File lib/sequel/adapters/mysql.rb, line 300 300: def delete(opts = (defarg=true;nil)) 301: execute_dui(defarg ? delete_sql : delete_sql(opts)){|c| c.affected_rows} 302: end
Yield all rows matching this dataset
# File lib/sequel/adapters/mysql.rb, line 305 305: def fetch_rows(sql) 306: execute(sql) do |r| 307: column_types = [] 308: @columns = r.fetch_fields.map{|f| column_types << f.type; output_identifier(f.name)} 309: while row = r.fetch_row 310: h = {} 311: @columns.each_with_index {|f, i| h[f] = convert_type(row[i], column_types[i])} 312: yield h 313: end 314: end 315: self 316: end
Insert a new value into this dataset
# File lib/sequel/adapters/mysql.rb, line 319 319: def insert(*values) 320: execute_dui(insert_sql(*values)){|c| c.insert_id} 321: end
Store the given type of prepared statement in the associated database with the given name.
# File lib/sequel/adapters/mysql.rb, line 325 325: def prepare(type, name=nil, values=nil) 326: ps = to_prepared_statement(type, values) 327: ps.extend(PreparedStatementMethods) 328: if name 329: ps.prepared_statement_name = name 330: db.prepared_statements[name] = ps 331: end 332: ps 333: end