Rename the main class to prevent conflicts:
git-svn-id: file:///home/svn/framework3/trunk@7974 4d416f70-5f16-0410-b530-b9f4589650da
This commit is contained in:
parent
8f47140ddf
commit
81b3470ef5
|
@ -3,7 +3,7 @@
|
|||
|
||||
require "#{File.dirname __FILE__}/error"
|
||||
|
||||
class Mysql
|
||||
class RbMysql
|
||||
class Charset
|
||||
def initialize(number, name, csname)
|
||||
@number, @name, @csname = number, name, csname
|
||||
|
@ -212,7 +212,7 @@ class Mysql
|
|||
# encoding [Encoding]
|
||||
def encoding
|
||||
enc = CHARSET_ENCODING[@name.downcase]
|
||||
raise Mysql::ClientError, "unsupported charset: #{@name}" unless enc
|
||||
raise RbMysql::ClientError, "unsupported charset: #{@name}" unless enc
|
||||
enc
|
||||
end
|
||||
|
||||
|
@ -253,3 +253,4 @@ class Mysql
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
# for compatibility
|
||||
|
||||
class Mysql
|
||||
class RbMysql
|
||||
class << self
|
||||
|
||||
def connect(*args)
|
||||
|
@ -211,7 +211,7 @@ class Mysql
|
|||
}
|
||||
end
|
||||
def inspect
|
||||
"#<Mysql::Field:#{@name}>"
|
||||
"#<RbMysql::Field:#{@name}>"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -265,3 +265,4 @@ class Mysql
|
|||
end
|
||||
Stmt = Statement
|
||||
end
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Copyright (C) 2003-2008 TOMITA Masahiro
|
||||
# mailto:tommy@tmtm.org
|
||||
|
||||
class Mysql
|
||||
class RbMysql
|
||||
# Command
|
||||
COM_SLEEP = 0
|
||||
COM_QUIT = 1
|
||||
|
@ -162,3 +162,4 @@ class Mysql
|
|||
CURSOR_TYPE_READ_ONLY = 1
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Copyright (C) 2003-2008 TOMITA Masahiro
|
||||
# mailto:tommy@tmtm.org
|
||||
|
||||
class Mysql
|
||||
class RbMysql
|
||||
class Error < StandardError
|
||||
end
|
||||
|
||||
|
@ -500,11 +500,11 @@ class Mysql
|
|||
errno = ServerError.const_get errname
|
||||
excname = errname.sub(/\AER_/,"").gsub(/(\A.|_.)([A-Z]+)/){$1+$2.downcase}.gsub(/_/,"")
|
||||
eval <<EOS
|
||||
class Mysql::#{excname} < Mysql::ServerError
|
||||
class RbMysql::#{excname} < RbMysql::ServerError
|
||||
ERRNO = #{errno}
|
||||
end
|
||||
EOS
|
||||
ServerError::ERROR_MAP[errno] = eval "Mysql::#{excname}"
|
||||
ServerError::ERROR_MAP[errno] = eval "RbMysql::#{excname}"
|
||||
end
|
||||
|
||||
# client side error
|
||||
|
@ -516,3 +516,4 @@ EOS
|
|||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ require "digest/sha1"
|
|||
require "thread"
|
||||
require "stringio"
|
||||
|
||||
class Mysql
|
||||
class RbMysql
|
||||
# MySQL network protocol
|
||||
class Protocol
|
||||
|
||||
|
@ -97,12 +97,12 @@ class Mysql
|
|||
when Field::TYPE_DATE, Field::TYPE_DATETIME, Field::TYPE_TIMESTAMP
|
||||
len = data.slice!(0).ord
|
||||
y, m, d, h, mi, s, bs = data.slice!(0,len).unpack("vCCCCCV")
|
||||
return Mysql::Time.new(y, m, d, h, mi, s, bs)
|
||||
return RbMysql::Time.new(y, m, d, h, mi, s, bs)
|
||||
when Field::TYPE_TIME
|
||||
len = data.slice!(0).ord
|
||||
sign, d, h, mi, s, sp = data.slice!(0,len).unpack("CVCCCV")
|
||||
h = d.to_i * 24 + h.to_i
|
||||
return Mysql::Time.new(0, 0, 0, h, mi, s, sign!=0, sp)
|
||||
return RbMysql::Time.new(0, 0, 0, h, mi, s, sign!=0, sp)
|
||||
when Field::TYPE_YEAR
|
||||
return data.slice!(0,2).unpack("v").first
|
||||
when Field::TYPE_BIT
|
||||
|
@ -164,7 +164,7 @@ class Mysql
|
|||
when String
|
||||
type = Field::TYPE_STRING
|
||||
val = Protocol.lcs(v)
|
||||
when Mysql::Time, ::Time
|
||||
when RbMysql::Time, ::Time
|
||||
type = Field::TYPE_DATETIME
|
||||
val = [7, v.year, v.month, v.day, v.hour, v.min, v.sec].pack("CvCCCCC")
|
||||
else
|
||||
|
@ -248,10 +248,10 @@ class Mysql
|
|||
f, errno, message = ret.unpack("Cva*") # Version 4.0 Error
|
||||
@sqlstate = ""
|
||||
end
|
||||
if Mysql::ServerError::ERROR_MAP.key? errno
|
||||
raise Mysql::ServerError::ERROR_MAP[errno].new(message, @sqlstate)
|
||||
if RbMysql::ServerError::ERROR_MAP.key? errno
|
||||
raise RbMysql::ServerError::ERROR_MAP[errno].new(message, @sqlstate)
|
||||
end
|
||||
raise Mysql::ServerError.new(message, @sqlstate)
|
||||
raise RbMysql::ServerError.new(message, @sqlstate)
|
||||
end
|
||||
ret
|
||||
end
|
||||
|
@ -492,7 +492,7 @@ class Mysql
|
|||
netvalues.concat n if v
|
||||
t
|
||||
end
|
||||
[Mysql::COM_STMT_EXECUTE, statement_id, cursor_type, 1, nbm, 1, types.pack("v*"), netvalues].pack("CVCVa*Ca*a*")
|
||||
[RbMysql::COM_STMT_EXECUTE, statement_id, cursor_type, 1, nbm, 1, types.pack("v*"), netvalues].pack("CVCVa*Ca*a*")
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -518,7 +518,7 @@ class Mysql
|
|||
end
|
||||
|
||||
def serialize
|
||||
[Mysql::COM_STMT_FETCH, statement_id, fetch_length].pack("CVV")
|
||||
[RbMysql::COM_STMT_FETCH, statement_id, fetch_length].pack("CVV")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -531,7 +531,7 @@ class Mysql
|
|||
end
|
||||
|
||||
def serialize
|
||||
[Mysql::COM_STMT_CLOSE, statement_id].pack("CV")
|
||||
[RbMysql::COM_STMT_CLOSE, statement_id].pack("CV")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -543,8 +543,9 @@ class Mysql
|
|||
end
|
||||
|
||||
def serialize
|
||||
[Mysql::COM_FIELD_LIST, "#{@table}\0#{@field}"].pack("Ca*")
|
||||
[RbMysql::COM_FIELD_LIST, "#{@table}\0#{@field}"].pack("Ca*")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue