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 289 289: def call(type, bind_arguments={}, values=nil) 290: ps = to_prepared_statement(type, values) 291: ps.extend(CallableStatementMethods) 292: ps.call(bind_arguments) 293: end
Delete rows matching this dataset
# File lib/sequel/adapters/mysql.rb, line 296 296: def delete 297: execute_dui(delete_sql){|c| c.affected_rows} 298: end
Yield all rows matching this dataset
# File lib/sequel/adapters/mysql.rb, line 301 301: def fetch_rows(sql) 302: execute(sql) do |r| 303: column_types = [] 304: @columns = r.fetch_fields.map{|f| column_types << f.type; output_identifier(f.name)} 305: while row = r.fetch_row 306: h = {} 307: @columns.each_with_index {|f, i| h[f] = convert_type(row[i], column_types[i])} 308: yield h 309: end 310: end 311: self 312: end
Insert a new value into this dataset
# File lib/sequel/adapters/mysql.rb, line 315 315: def insert(*values) 316: execute_dui(insert_sql(*values)){|c| c.insert_id} 317: end
Store the given type of prepared statement in the associated database with the given name.
# File lib/sequel/adapters/mysql.rb, line 321 321: def prepare(type, name=nil, values=nil) 322: ps = to_prepared_statement(type, values) 323: ps.extend(PreparedStatementMethods) 324: if name 325: ps.prepared_statement_name = name 326: db.prepared_statements[name] = ps 327: end 328: ps 329: end