lib/og/adapters/mysql.rb in og-0.15.0 vs lib/og/adapters/mysql.rb in og-0.16.0

- old
+ new

@@ -1,19 +1,17 @@ # * George Moschovitis <gm@navel.gr> # (c) 2004-2005 Navel, all rights reserved. -# $Id: mysql.rb 326 2005-03-28 11:07:17Z gmosx $ +# $Id: mysql.rb 17 2005-04-14 16:03:40Z gmosx $ begin require 'mysql' rescue Object => ex Logger.error 'Ruby-Mysql bindings are not installed!' Logger.error ex end -require 'og/adapter' -require 'og/connection' -require 'glue/attribute' +require 'og/adapters/base' module Og # The MySQL adapter. This adapter communicates with # an MySQL rdbms. For extra documentation see @@ -92,22 +90,20 @@ def props_for_insert(klass) klass.__props.reject { |p| :oid == p.symbol } end - def insert_code(klass, db, pre_cb, post_cb) + def insert_code(klass, db) props = props_for_insert(klass) values = props.collect { |p| write_prop(p) }.join(',') sql = "INSERT INTO #{klass::DBTABLE} (#{props.collect {|p| p.name}.join(',')}) VALUES (#{values})" %{ - #{pre_cb} conn.store.query_with_result = false conn.store.query "#{sql}" @oid = conn.store.insert_id() - #{post_cb} } end def new_connection(db) return MysqlConnection.new(db) @@ -312,11 +308,11 @@ def read_one(res, klass) return nil unless valid_res?(res) row = res.fetch_row - obj = klass.new + obj = klass.allocate obj.og_read(row) res.free return obj end @@ -327,10 +323,10 @@ objects = [] for tuple in (0...res.num_rows) row = res.fetch_row - obj = klass.new + obj = klass.allocate obj.og_read(row) objects << obj end