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 302 302: def call(type, bind_arguments={}, values=nil) 303: ps = to_prepared_statement(type, values) 304: ps.extend(CallableStatementMethods) 305: ps.call(bind_arguments) 306: end
Delete rows matching this dataset
# File lib/sequel/adapters/mysql.rb, line 309 309: def delete 310: execute_dui(delete_sql){|c| c.affected_rows} 311: end
Yield all rows matching this dataset
# File lib/sequel/adapters/mysql.rb, line 314 314: def fetch_rows(sql) 315: execute(sql) do |r| 316: i = -1 317: cols = r.fetch_fields.map{|f| [output_identifier(f.name), MYSQL_TYPES[f.type], i+=1]} 318: @columns = cols.map{|c| c.first} 319: while row = r.fetch_row 320: h = {} 321: cols.each{|n, p, i| v = row[i]; h[n] = (v && p) ? p.call(v) : v} 322: yield h 323: end 324: end 325: self 326: end
Insert a new value into this dataset
# File lib/sequel/adapters/mysql.rb, line 329 329: def insert(*values) 330: execute_dui(insert_sql(*values)){|c| c.insert_id} 331: end
Store the given type of prepared statement in the associated database with the given name.
# File lib/sequel/adapters/mysql.rb, line 335 335: def prepare(type, name=nil, values=nil) 336: ps = to_prepared_statement(type, values) 337: ps.extend(PreparedStatementMethods) 338: if name 339: ps.prepared_statement_name = name 340: db.prepared_statements[name] = ps 341: end 342: ps 343: end