30: def connect(dbname, user, auth, attr)
31:
32: hash = DBI::Utils.parse_params(dbname)
33:
34: hash['host'] ||= 'localhost'
35:
36:
37: hash['port'] = hash['port'].to_i unless hash['port'].nil?
38: hash['flag'] = hash['flag'].nil? ? 0 : hash['flag'] = hash['flag'].to_i
39:
40: handle = ::Mysql.init
41:
42:
43:
44: !hash['mysql_read_default_file'].nil? and
45: handle.options(::Mysql::READ_DEFAULT_FILE,
46: hash['mysql_read_default_file'])
47: !hash['mysql_read_default_group'].nil? and
48: handle.options(::Mysql::READ_DEFAULT_GROUP,
49: hash['mysql_read_default_group'])
50:
51:
52: hash['mysql_compression'].to_i != 0 and
53: handle.options(::Mysql::OPT_COMPRESS, nil)
54: hash['mysql_local_infile'].to_i != 0 and
55: handle.options(::Mysql::OPT_LOCAL_INFILE, true)
56:
57:
58: if !hash['mysql_client_found_rows'].nil?
59: if hash['mysql_client_found_rows'].to_i != 0
60: hash['flag'] |= ::Mysql::CLIENT_FOUND_ROWS
61: else
62: hash['flag'] &= ~::Mysql::CLIENT_FOUND_ROWS
63: end
64: end
65:
66: handle.connect(hash['host'], user, auth, hash['database'], hash['port'], hash['socket'], hash['flag'])
67:
68: return Database.new(handle, attr)
69: rescue MyError => err
70: error(err)
71: end