mysql 2.7.1-mswin32
Sign up to get free protection for your applications and to get access to all the features.
- data/README +27 -0
- data/Rakefile +59 -0
- data/docs/README.html +1017 -0
- data/ext/extconf.rb +18 -0
- data/ext/extconf.rb.orig +67 -0
- data/ext/mysql.c.in +2184 -0
- data/ext/mysql.so +0 -0
- data/ext/test.rb +1367 -0
- metadata +57 -0
data/README
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
mysql-win - A win32 native build of the MySQL API module for Ruby.
|
2
|
+
|
3
|
+
Copyright (c) 2006 Kevin Williams
|
4
|
+
|
5
|
+
= Description
|
6
|
+
|
7
|
+
A win32 native build of the MySQL API module for Ruby.
|
8
|
+
|
9
|
+
= Dependencies
|
10
|
+
|
11
|
+
none
|
12
|
+
|
13
|
+
= Installation
|
14
|
+
|
15
|
+
This package is only available for RubyGems, and only for Windows, so the installation method is:
|
16
|
+
|
17
|
+
C:\> gem install mysql
|
18
|
+
|
19
|
+
= Documentation
|
20
|
+
|
21
|
+
Please see the README.html file in the 'docs' folder.
|
22
|
+
|
23
|
+
= Contact
|
24
|
+
|
25
|
+
Author: Kevin Williams
|
26
|
+
* Web: http://mysql-win.rubyforge.org
|
27
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rubygems'
|
3
|
+
require 'rake/clean'
|
4
|
+
require 'fileutils'
|
5
|
+
#require 'date'
|
6
|
+
include FileUtils
|
7
|
+
|
8
|
+
CLEAN.include ["ext/*.{log,c,so,obj,pdb,lib,def,exp,manifest}", "ext/Makefile", "*.gem"]
|
9
|
+
|
10
|
+
name="mysql"
|
11
|
+
version="2.7.1"
|
12
|
+
|
13
|
+
desc "Do everything, baby!"
|
14
|
+
task :default => [:package]
|
15
|
+
|
16
|
+
#task :package => [:clobber,:compile,:test,:makegem]
|
17
|
+
task :package => [:clean,:compile,:makegem]
|
18
|
+
|
19
|
+
desc "Compiles all extensions"
|
20
|
+
task :compile do
|
21
|
+
cd "ext" do
|
22
|
+
sh %{ ruby extconf.rb --with-mysql-include=C:/Progra~1/MySQL/MySQLS~1.0/include --with-mysql-lib=C:/Progra~1/MySQL/MySQLS~1.0/lib/opt }
|
23
|
+
sh %{ nmake }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
desc "runs the given tests"
|
28
|
+
task :test do
|
29
|
+
cd "ext" do
|
30
|
+
# TODO: improve test setup so that tests pass with authentication
|
31
|
+
ruby "test.rb", %{#{ENV["TESTOPTS"]}}
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
desc "Build a binary gem for Win32"
|
36
|
+
task :makegem do
|
37
|
+
spec = Gem::Specification.new do |s|
|
38
|
+
s.name = %{#{name}}
|
39
|
+
s.version = %{#{version}}
|
40
|
+
s.author = "Kevin Williams"
|
41
|
+
s.email = "kevin@bantamtech.com"
|
42
|
+
s.homepage="http://mysql-win.rubyforge.org"
|
43
|
+
s.summary = "A win32-native build of the MySQL API module for Ruby."
|
44
|
+
s.description = s.summary
|
45
|
+
s.rubyforge_project = s.name
|
46
|
+
s.files += %w(docs ext/mysql.so ext/extconf.rb ext/extconf.rb.orig ext/mysql.c.in ext/test.rb README Rakefile)
|
47
|
+
s.rdoc_options << '--exclude' << 'ext' << '--main' << 'README'
|
48
|
+
s.extra_rdoc_files = ["README", "docs/README.html"]
|
49
|
+
s.has_rdoc = true
|
50
|
+
s.require_path = 'ext'
|
51
|
+
s.autorequire = 'mysql'
|
52
|
+
s.required_ruby_version = '>= 1.8.2'
|
53
|
+
s.platform = Gem::Platform::WIN32
|
54
|
+
end
|
55
|
+
|
56
|
+
Gem::manage_gems
|
57
|
+
Gem::Builder.new(spec).build
|
58
|
+
end
|
59
|
+
|
data/docs/README.html
ADDED
@@ -0,0 +1,1017 @@
|
|
1
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
2
|
+
<!-- $Id: README.html,v 1.18 2006/06/04 14:39:53 tommy Exp $ -->
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta http-equiv="content-style-type" content="text/css">
|
6
|
+
<link rel=stylesheet type="text/css" href="tommy.css">
|
7
|
+
<link rev=made href="mailto:tommy@tmtm.org">
|
8
|
+
<title>MySQL/Ruby</title>
|
9
|
+
</head>
|
10
|
+
|
11
|
+
<body>
|
12
|
+
<h1>MySQL/Ruby</h1>
|
13
|
+
<p><a href="README_ja.html">[Japanese]</a></p>
|
14
|
+
<hr>
|
15
|
+
<p>
|
16
|
+
This is the <a href="http://www.mysql.com">MySQL</a> API module for Ruby.
|
17
|
+
It provides the same functions for Ruby programs that the MySQL C API provides for C programs.
|
18
|
+
</p>
|
19
|
+
|
20
|
+
<h2>Download</h2>
|
21
|
+
<a href="http://tmtm.org/downloads/mysql/ruby/">tmtm.org</a>
|
22
|
+
|
23
|
+
<h2>Requirement</h2>
|
24
|
+
<ul>
|
25
|
+
<li>MySQL 4.1.15/5.0.16
|
26
|
+
<li>Ruby 1.8.4
|
27
|
+
</ul>
|
28
|
+
<p>
|
29
|
+
The module may work for other versions, but that has not been verified.
|
30
|
+
</p>
|
31
|
+
|
32
|
+
<h2>License</h2>
|
33
|
+
<p>
|
34
|
+
This program is under <a href="http://www.ruby-lang.org/en/LICENSE.txt">Ruby's license</a>.
|
35
|
+
</p>
|
36
|
+
|
37
|
+
<h2>Install</h2>
|
38
|
+
<p>
|
39
|
+
1st:
|
40
|
+
</p>
|
41
|
+
<pre class="code">
|
42
|
+
% ruby extconf.rb
|
43
|
+
</pre>
|
44
|
+
<p>
|
45
|
+
or
|
46
|
+
</p>
|
47
|
+
<pre class="code">
|
48
|
+
% ruby extconf.rb --with-mysql-dir=/usr/local/mysql
|
49
|
+
</pre>
|
50
|
+
<p>
|
51
|
+
or
|
52
|
+
</p>
|
53
|
+
<pre clas="code">
|
54
|
+
% ruby extconf.rb --with-mysql-config
|
55
|
+
</pre>
|
56
|
+
<p>
|
57
|
+
then
|
58
|
+
</p>
|
59
|
+
<pre>
|
60
|
+
% make
|
61
|
+
</pre>
|
62
|
+
<p>
|
63
|
+
extconf.rb has following options:
|
64
|
+
</p>
|
65
|
+
<dl>
|
66
|
+
<dt>--with-mysql-include=<i>dir</i>
|
67
|
+
<dd>
|
68
|
+
MySQL header file directory. Default is /usr/local/include.
|
69
|
+
|
70
|
+
<dt>--with-mysql-lib=<i>dir</i>
|
71
|
+
<dd>
|
72
|
+
MySQL library directory. Default is /usr/local/lib.
|
73
|
+
|
74
|
+
<dt>--with-mysql-dir=<i>dir</i>
|
75
|
+
<dd>
|
76
|
+
Same as --with-mysql-include=<i>dir</i>/include,
|
77
|
+
--with-mysql-lib=<i>dir</i>/lib.
|
78
|
+
|
79
|
+
<dt>--with-mysql-config[=<i>/path/to/mysql_config</i>]
|
80
|
+
<dd>
|
81
|
+
Get compile-parameter from mysql_config command.
|
82
|
+
</dl>
|
83
|
+
<p>
|
84
|
+
2nd:
|
85
|
+
</p>
|
86
|
+
<pre class="code">
|
87
|
+
% ruby ./test.rb [<i>hostname</i> [<i>user</i> [<i>passwd</i> [<i>dbname</i> [<i>port</i> [<i>socket</i> [<i>flag</i>]]]]]]]
|
88
|
+
</pre>
|
89
|
+
|
90
|
+
<p>
|
91
|
+
3rd:
|
92
|
+
</p>
|
93
|
+
<pre class="code">
|
94
|
+
# make install
|
95
|
+
</pre>
|
96
|
+
|
97
|
+
<h3>Note</h3>
|
98
|
+
<p>
|
99
|
+
If you get error like 'libmysqlclient not found' when testing,
|
100
|
+
you need to specify the directory in which the library is
|
101
|
+
located so that make can find it.
|
102
|
+
</p>
|
103
|
+
<pre class="code">
|
104
|
+
% env LD_RUN_PATH=<i>libmysqlclient.so directory</i> make
|
105
|
+
</pre>
|
106
|
+
|
107
|
+
<h2>Usage</h2>
|
108
|
+
<p>
|
109
|
+
The names of methods provided by this module basically are the
|
110
|
+
same as the names of the functions in the C API, except that the
|
111
|
+
Ruby method names do not begin with a 'mysql_' prefix. For
|
112
|
+
example, the Ruby query() method corresponds to the C API
|
113
|
+
mysql_query() function. For details on the use of each Ruby
|
114
|
+
method, see the descriptions of the corresponding C functions in
|
115
|
+
the MySQL Reference Manual.
|
116
|
+
</p>
|
117
|
+
<p>
|
118
|
+
Some Ruby methods may be invoked under other names that serve as
|
119
|
+
equivalent aliases, as noted below.
|
120
|
+
</p>
|
121
|
+
<p>
|
122
|
+
If an error occurs when a method executes, it raises a
|
123
|
+
Mysql::Error exception.
|
124
|
+
</p>
|
125
|
+
|
126
|
+
<h2>Mysql class</h2>
|
127
|
+
<h3>CLASS METHODS</h3>
|
128
|
+
<dl>
|
129
|
+
<dt>init()
|
130
|
+
<dd>
|
131
|
+
<p>
|
132
|
+
It return Mysql object. It not connect to mysqld.
|
133
|
+
</p>
|
134
|
+
|
135
|
+
<dt>real_connect(host=nil, user=nil, passwd=nil, db=nil, port=nil, sock=nil, flag=nil)
|
136
|
+
<dt>connect(host=nil, user=nil, passwd=nil, db=nil, port=nil, sock=nil, flag=nil)
|
137
|
+
<dt>new(host=nil, user=nil, passwd=nil, db=nil, port=nil, sock=nil, flag=nil)
|
138
|
+
<dd>
|
139
|
+
<p>
|
140
|
+
connect to mysqld and return Mysql object.
|
141
|
+
</p>
|
142
|
+
|
143
|
+
<dt>escape_string(str)
|
144
|
+
<dt>quote(str)
|
145
|
+
<dd>
|
146
|
+
<p>
|
147
|
+
quote string for insert/update.
|
148
|
+
</p>
|
149
|
+
|
150
|
+
<dt>get_client_info()
|
151
|
+
<dt>client_info()
|
152
|
+
<dd>
|
153
|
+
<p>
|
154
|
+
return client version information.
|
155
|
+
</p>
|
156
|
+
|
157
|
+
<dt>get_client_version()
|
158
|
+
<dt>client_version()
|
159
|
+
<dd>
|
160
|
+
<p>
|
161
|
+
return client version as number.
|
162
|
+
</p>
|
163
|
+
|
164
|
+
<dt>debug(str)
|
165
|
+
<dd>
|
166
|
+
<p>
|
167
|
+
same as C API mysql_debug().
|
168
|
+
</p>
|
169
|
+
</dl>
|
170
|
+
|
171
|
+
<h3>OBJECT METHODS</h3>
|
172
|
+
<dl>
|
173
|
+
<dt>options(opt, val=nil)
|
174
|
+
<dd>
|
175
|
+
<p>
|
176
|
+
same as C API mysql_options().
|
177
|
+
</p>
|
178
|
+
|
179
|
+
<dt>real_connect(host=nil, user=nil, passwd=nil, db=nil, port=nil, sock=nil, flag=nil)
|
180
|
+
<dt>connect(host=nil, user=nil, passwd=nil, db=nil, port=nil, sock=nil, flag=nil)
|
181
|
+
<dd>
|
182
|
+
<p>
|
183
|
+
same as Mysql.real_connect().
|
184
|
+
</p>
|
185
|
+
|
186
|
+
<dt>affected_rows()
|
187
|
+
<dd>
|
188
|
+
<p>
|
189
|
+
return affected rows.
|
190
|
+
</p>
|
191
|
+
|
192
|
+
<dt>autocommit(mode)
|
193
|
+
<dd>
|
194
|
+
<p>
|
195
|
+
set autocommit mode.
|
196
|
+
</p>
|
197
|
+
|
198
|
+
<dt>change_user(user=nil, passwd=nil, db=nil)
|
199
|
+
<dd>
|
200
|
+
<p>
|
201
|
+
change user.
|
202
|
+
</p>
|
203
|
+
|
204
|
+
<dt>character_set_name()
|
205
|
+
<dd>
|
206
|
+
<p>
|
207
|
+
return character set.
|
208
|
+
</p>
|
209
|
+
|
210
|
+
<dt>close()
|
211
|
+
<dd>
|
212
|
+
<p>
|
213
|
+
close connection.
|
214
|
+
</p>
|
215
|
+
|
216
|
+
<dt>commit()
|
217
|
+
<dd>
|
218
|
+
<p>
|
219
|
+
commit transaction.
|
220
|
+
</p>
|
221
|
+
|
222
|
+
<dt>create_db(db)
|
223
|
+
<dd>
|
224
|
+
<p>
|
225
|
+
create database.
|
226
|
+
</p>
|
227
|
+
|
228
|
+
<dt>drop_db(db)
|
229
|
+
<dd>
|
230
|
+
<p>
|
231
|
+
drop database.
|
232
|
+
</p>
|
233
|
+
|
234
|
+
<dt>dump_debug_info()
|
235
|
+
<dd>
|
236
|
+
<p>
|
237
|
+
same as C API mysql_dump_debug_info().
|
238
|
+
</p>
|
239
|
+
|
240
|
+
<dt>errno()
|
241
|
+
<dd>
|
242
|
+
<p>
|
243
|
+
return error number.
|
244
|
+
</p>
|
245
|
+
|
246
|
+
<dt>error()
|
247
|
+
<dd>
|
248
|
+
<p>
|
249
|
+
return error message.
|
250
|
+
</p>
|
251
|
+
|
252
|
+
<dt>escape_string(str)
|
253
|
+
<dt>quote(str)
|
254
|
+
<dd>
|
255
|
+
<p>
|
256
|
+
quote strings for insert/update.
|
257
|
+
same as C API mysql_real_escape_string().
|
258
|
+
</p>
|
259
|
+
|
260
|
+
<dt>field_count()
|
261
|
+
<dd>
|
262
|
+
<p>
|
263
|
+
return number of columns of last query.
|
264
|
+
</p>
|
265
|
+
|
266
|
+
<dt>get_client_info()
|
267
|
+
<dt>client_info()
|
268
|
+
<dd>
|
269
|
+
<p>
|
270
|
+
return client version information.
|
271
|
+
</p>
|
272
|
+
|
273
|
+
<dt>get_client_version()
|
274
|
+
<dt>client_version()
|
275
|
+
<dd>
|
276
|
+
<p>
|
277
|
+
return client version number.
|
278
|
+
</p>
|
279
|
+
|
280
|
+
<dt>get_host_info()
|
281
|
+
<dt>host_info()
|
282
|
+
<dd>
|
283
|
+
<p>
|
284
|
+
return connection information.
|
285
|
+
</p>
|
286
|
+
|
287
|
+
<dt>get_proto_info()
|
288
|
+
<dt>proto_info()
|
289
|
+
<dd>
|
290
|
+
<p>
|
291
|
+
return connection protocol version.
|
292
|
+
</p>
|
293
|
+
|
294
|
+
<dt>get_server_info()
|
295
|
+
<dt>server_info()
|
296
|
+
<dd>
|
297
|
+
<p>
|
298
|
+
return server version information.
|
299
|
+
</p>
|
300
|
+
|
301
|
+
<dt>get_server_version()
|
302
|
+
<dt>server_version()
|
303
|
+
<dd>
|
304
|
+
<p>
|
305
|
+
return server version number.
|
306
|
+
</p>
|
307
|
+
|
308
|
+
<dt>info()
|
309
|
+
<dd>
|
310
|
+
<p>
|
311
|
+
return information of last query.
|
312
|
+
</p>
|
313
|
+
|
314
|
+
<dt>insert_id()
|
315
|
+
<dd>
|
316
|
+
<p>
|
317
|
+
return last AUTO_INCREMENT value.
|
318
|
+
</p>
|
319
|
+
|
320
|
+
<dt>kill(id)
|
321
|
+
<dd>
|
322
|
+
<p>
|
323
|
+
kill thread.
|
324
|
+
</p>
|
325
|
+
|
326
|
+
<dt>list_dbs(db=nil)
|
327
|
+
<dd>
|
328
|
+
<p>
|
329
|
+
return database list.
|
330
|
+
</p>
|
331
|
+
|
332
|
+
<dt>list_fields(table, field=nil)
|
333
|
+
<dd>
|
334
|
+
<p>
|
335
|
+
return Mysql::Result object.
|
336
|
+
</p>
|
337
|
+
|
338
|
+
<dt>list_processes()
|
339
|
+
<dd>
|
340
|
+
<p>
|
341
|
+
return Mysql::Result object.
|
342
|
+
</p>
|
343
|
+
|
344
|
+
<dt>list_tables(table=nil)
|
345
|
+
<dd>
|
346
|
+
<p>
|
347
|
+
return table list Array.
|
348
|
+
</p>
|
349
|
+
|
350
|
+
<dt>more_results?()
|
351
|
+
<dd>
|
352
|
+
<p>
|
353
|
+
returns true if more results exist from the currently executed query.
|
354
|
+
</p>
|
355
|
+
|
356
|
+
<dt>next_result()
|
357
|
+
<dd>
|
358
|
+
<p>
|
359
|
+
returns true if more results exist from the currently executed query.
|
360
|
+
after this, you do store_result() to get result table of query.
|
361
|
+
</p>
|
362
|
+
|
363
|
+
<dt>ping()
|
364
|
+
<dd>
|
365
|
+
<p>
|
366
|
+
check server.
|
367
|
+
</p>
|
368
|
+
|
369
|
+
<dt>prepare(q)
|
370
|
+
<dd>
|
371
|
+
<p>
|
372
|
+
</p>
|
373
|
+
|
374
|
+
<dt>query(q)
|
375
|
+
<dt>real_query(q)
|
376
|
+
<dd>
|
377
|
+
<p>
|
378
|
+
do query and store_result(). return Mysql::Result object.
|
379
|
+
If query_with_result is false, it does not store_result().
|
380
|
+
</p>
|
381
|
+
|
382
|
+
<dt>query(q) {|res| ...}
|
383
|
+
<dt>real_query(q) {|res| ...}
|
384
|
+
<dd>
|
385
|
+
<p>
|
386
|
+
do query and execute block with Mysql::Result object.
|
387
|
+
if you specify multiple query, then repeat block.
|
388
|
+
set_server_option(Mysql::OPTION_MULTI_STATEMENTS) is executed automatically.
|
389
|
+
</p>
|
390
|
+
|
391
|
+
<dt>refresh(r)
|
392
|
+
<dd>
|
393
|
+
<p>
|
394
|
+
flush server log or cache.
|
395
|
+
</p>
|
396
|
+
|
397
|
+
<dt>reload()
|
398
|
+
<dd>
|
399
|
+
<p>
|
400
|
+
reload access privilege table.
|
401
|
+
</p>
|
402
|
+
|
403
|
+
<dt>rollback()
|
404
|
+
<dd>
|
405
|
+
<p>
|
406
|
+
rollback transaction.
|
407
|
+
</p>
|
408
|
+
|
409
|
+
<dt>select_db(db)
|
410
|
+
<dd>
|
411
|
+
<p>
|
412
|
+
select database.
|
413
|
+
</p>
|
414
|
+
|
415
|
+
<dt>set_server_option(opt)
|
416
|
+
<dd>
|
417
|
+
<p>
|
418
|
+
set option to server.
|
419
|
+
options is one of Mysql::OPTION_MULTI_STATEMENTS_ON, Mysql::OPTION_MULTI_STATEMENTS_OFF.
|
420
|
+
</p>
|
421
|
+
|
422
|
+
<dt>shutdown()
|
423
|
+
<dd>
|
424
|
+
<p>
|
425
|
+
shutdown server.
|
426
|
+
</p>
|
427
|
+
|
428
|
+
<dt>ssl_set(key=nil, cert=nil, ca=nil, capath=nil, cipher=nil)
|
429
|
+
<dd>
|
430
|
+
<p>
|
431
|
+
use SSL.
|
432
|
+
</p>
|
433
|
+
|
434
|
+
<dt>stat()
|
435
|
+
<dd>
|
436
|
+
<p>
|
437
|
+
return server status.
|
438
|
+
</p>
|
439
|
+
|
440
|
+
<dt>stmt_init()
|
441
|
+
<dd>
|
442
|
+
<p>
|
443
|
+
return Mysql::Stmt class object.
|
444
|
+
</p>
|
445
|
+
|
446
|
+
<dt>store_result()
|
447
|
+
<dd>
|
448
|
+
<p>
|
449
|
+
return Mysql::Result object.
|
450
|
+
</p>
|
451
|
+
|
452
|
+
<dt>thread_id()
|
453
|
+
<dd>
|
454
|
+
<p>
|
455
|
+
retrun thread id.
|
456
|
+
</p>
|
457
|
+
|
458
|
+
<dt>use_result()
|
459
|
+
<dd>
|
460
|
+
<p>
|
461
|
+
return Mysql::Result object.
|
462
|
+
</p>
|
463
|
+
|
464
|
+
<dt>warning_count()
|
465
|
+
<dd>
|
466
|
+
<p>
|
467
|
+
return warning count last query.
|
468
|
+
</p>
|
469
|
+
</dl>
|
470
|
+
|
471
|
+
<h3>OBJECT VARIABLES</h3>
|
472
|
+
|
473
|
+
<dl>
|
474
|
+
<dt>query_with_result
|
475
|
+
<dd>
|
476
|
+
<p>
|
477
|
+
If true, query() also invokes store_result() and returns a
|
478
|
+
Mysql::Result object. Default is true.
|
479
|
+
</p>
|
480
|
+
|
481
|
+
<dt>reconnect
|
482
|
+
<dd>
|
483
|
+
<p>
|
484
|
+
If true, reconnect to server automatically when disconect to server.
|
485
|
+
Default is false.
|
486
|
+
</p>
|
487
|
+
|
488
|
+
</dl>
|
489
|
+
|
490
|
+
<h2>Mysql::Result class</h2>
|
491
|
+
|
492
|
+
<h3>OBJECT METHODS</h3>
|
493
|
+
<dl>
|
494
|
+
<dt>free()
|
495
|
+
<dd>
|
496
|
+
<p>
|
497
|
+
free memory of result table.
|
498
|
+
</p>
|
499
|
+
|
500
|
+
<dt>data_seek(offset)
|
501
|
+
<dd>
|
502
|
+
<p>
|
503
|
+
seek row.
|
504
|
+
</p>
|
505
|
+
|
506
|
+
<dt>fetch_field()
|
507
|
+
<dd>
|
508
|
+
<p>
|
509
|
+
return next Mysql::Field object.
|
510
|
+
</p>
|
511
|
+
|
512
|
+
<dt>fetch_fields()
|
513
|
+
<dd>
|
514
|
+
<p>
|
515
|
+
return Array of Mysql::Field object.
|
516
|
+
</p>
|
517
|
+
|
518
|
+
<dt>fetch_field_direct(fieldnr)
|
519
|
+
<dd>
|
520
|
+
<p>
|
521
|
+
return Mysql::Field object.
|
522
|
+
</p>
|
523
|
+
|
524
|
+
<dt>fetch_lengths()
|
525
|
+
<dd>
|
526
|
+
<p>
|
527
|
+
return Array of field length.
|
528
|
+
</p>
|
529
|
+
|
530
|
+
<dt>fetch_row()
|
531
|
+
<dd>
|
532
|
+
<p>
|
533
|
+
return row as Array.
|
534
|
+
</p>
|
535
|
+
|
536
|
+
<dt>fetch_hash(with_table=false)
|
537
|
+
<dd>
|
538
|
+
<p>
|
539
|
+
return row as Hash.
|
540
|
+
If with_table is true, hash key format is "tablename.fieldname".
|
541
|
+
</p>
|
542
|
+
|
543
|
+
<dt>field_seek(offset)
|
544
|
+
<dd>
|
545
|
+
<p>
|
546
|
+
seek field.
|
547
|
+
</p>
|
548
|
+
|
549
|
+
<dt>field_tell()
|
550
|
+
<dd>
|
551
|
+
<p>
|
552
|
+
return field position.
|
553
|
+
</p>
|
554
|
+
|
555
|
+
<dt>num_fields()
|
556
|
+
<dd>
|
557
|
+
<p>
|
558
|
+
return number of fields.
|
559
|
+
</p>
|
560
|
+
|
561
|
+
<dt>num_rows()
|
562
|
+
<dd>
|
563
|
+
<p>
|
564
|
+
return number of rows.
|
565
|
+
</p>
|
566
|
+
|
567
|
+
<dt>row_seek(offset)
|
568
|
+
<dd>
|
569
|
+
<p>
|
570
|
+
seek row.
|
571
|
+
</p>
|
572
|
+
|
573
|
+
<dt>row_tell()
|
574
|
+
<dd>
|
575
|
+
<p>
|
576
|
+
return row position.
|
577
|
+
</p>
|
578
|
+
</dl>
|
579
|
+
|
580
|
+
<h3>ITERATOR</h3>
|
581
|
+
<dl>
|
582
|
+
<dt>each() {|x| ...}
|
583
|
+
<dd>
|
584
|
+
<p>
|
585
|
+
'x' is array of column values.
|
586
|
+
</p>
|
587
|
+
|
588
|
+
<dt>each_hash(with_table=false) {|x| ...}
|
589
|
+
<dd>
|
590
|
+
<p>
|
591
|
+
'x' is hash of column values, and the keys are the column names.
|
592
|
+
</p>
|
593
|
+
</dl>
|
594
|
+
|
595
|
+
<h2>Mysql::Field class</h2>
|
596
|
+
|
597
|
+
<h3>OBJECT VARIABLES(read only)</h3>
|
598
|
+
<dl>
|
599
|
+
<dt>name<dd>field name
|
600
|
+
<dt>table<dd>table name
|
601
|
+
<dt>def<dd>default value
|
602
|
+
<dt>type<dd>field type
|
603
|
+
<dt>length<dd>field length
|
604
|
+
<dt>max_length<dd>max field length
|
605
|
+
<dt>flags<dd>field flag
|
606
|
+
<dt>decimals<dd>number of decimals
|
607
|
+
</dl>
|
608
|
+
|
609
|
+
<h3>OBJECT METHODS</h3>
|
610
|
+
<dl>
|
611
|
+
<dt>hash()
|
612
|
+
<dd>
|
613
|
+
<p>
|
614
|
+
return field as Hash.
|
615
|
+
</p>
|
616
|
+
<p>
|
617
|
+
ex.) obj.name == obj.hash['name']
|
618
|
+
</p>
|
619
|
+
|
620
|
+
<dt>is_not_null?()
|
621
|
+
<dd>
|
622
|
+
<p>
|
623
|
+
True if this field is defined as NOT NULL.
|
624
|
+
</p>
|
625
|
+
|
626
|
+
<dt>is_num?()
|
627
|
+
<dd>
|
628
|
+
<p>
|
629
|
+
True if this field type is numeric.
|
630
|
+
</p>
|
631
|
+
|
632
|
+
<dt>is_pri_key?()
|
633
|
+
<dd>
|
634
|
+
<p>
|
635
|
+
True if this field is a primary key.
|
636
|
+
</p>
|
637
|
+
|
638
|
+
<dt>inspect()
|
639
|
+
<dd>
|
640
|
+
<p>
|
641
|
+
return "#<Mysql::Field:fieldname>"
|
642
|
+
</p>
|
643
|
+
</dl>
|
644
|
+
|
645
|
+
<h2>Mysql::Stmt class</h2>
|
646
|
+
<p>
|
647
|
+
Example:
|
648
|
+
</p>
|
649
|
+
<pre class="code">
|
650
|
+
my = Mysql.new(hostname, username, password, databasename)
|
651
|
+
st = my.prepare("insert into tblname (col1,col2,col3) values (?,?,?)")
|
652
|
+
st.execute("abc",123,Time.now)
|
653
|
+
st.prepare("select col1,col2,col3 from tblname")
|
654
|
+
st.execute
|
655
|
+
st.fetch # => ["abc", 123, #<Mysql::Time:2005-07-24 23:52:55>]
|
656
|
+
st.close
|
657
|
+
</pre>
|
658
|
+
|
659
|
+
<h3>OBJECT METHODS</h3>
|
660
|
+
<dl>
|
661
|
+
<dt>affected_rows()
|
662
|
+
<dd>
|
663
|
+
<p>
|
664
|
+
</p>
|
665
|
+
|
666
|
+
<dt>bind_result(class, ...)
|
667
|
+
<dd>
|
668
|
+
<p>
|
669
|
+
</p>
|
670
|
+
|
671
|
+
<dt>close()
|
672
|
+
<dd>
|
673
|
+
<p>
|
674
|
+
</p>
|
675
|
+
|
676
|
+
<dt>data_seek(offset)
|
677
|
+
<dd>
|
678
|
+
<p>
|
679
|
+
</p>
|
680
|
+
|
681
|
+
<dt>execute(arg, ...)
|
682
|
+
<dd>
|
683
|
+
<p>
|
684
|
+
</p>
|
685
|
+
|
686
|
+
<dt>fetch()
|
687
|
+
<dd>
|
688
|
+
<p>
|
689
|
+
</p>
|
690
|
+
<p>
|
691
|
+
Type mapping:
|
692
|
+
</p>
|
693
|
+
<table>
|
694
|
+
<tr><th>MySQL type<th>Ruby class
|
695
|
+
<tr><td>TINYINT, SMALLINT, MEDIUMINT, YEAR<td>Fixnum
|
696
|
+
<tr><td>INT, BIGINT<td>Fixnum or Bignum
|
697
|
+
<tr><td>FLOAT, DOUBLE<td>Float
|
698
|
+
<tr><td>DECIMAL<td>String
|
699
|
+
<tr><td>DATE, DATETIME, TIMESTAMP, TIME<td>Mysql::Time
|
700
|
+
<tr><td>CHAR, VARCHAR, BINARY, VARBINARY, TINYBLOB, TINYTEXT, TINYBLOB, TINYTEXT, MEDIUMBLOB, MEDIUMTEXT, LONGBLOB, LONGTEXT, ENUM, SET<td>String
|
701
|
+
<tr><td>NULL<td>NilClass
|
702
|
+
</table>
|
703
|
+
|
704
|
+
<dt>field_count()
|
705
|
+
<dd>
|
706
|
+
<p>
|
707
|
+
</p>
|
708
|
+
|
709
|
+
<dt>free_result()
|
710
|
+
<dd>
|
711
|
+
<p>
|
712
|
+
</p>
|
713
|
+
|
714
|
+
<dt>insert_id()
|
715
|
+
<dd>
|
716
|
+
<p>
|
717
|
+
</p>
|
718
|
+
|
719
|
+
<dt>num_rows()
|
720
|
+
<dd>
|
721
|
+
<p>
|
722
|
+
</p>
|
723
|
+
|
724
|
+
<dt>param_count()
|
725
|
+
<dd>
|
726
|
+
<p>
|
727
|
+
</p>
|
728
|
+
|
729
|
+
<dt>prepare(q)
|
730
|
+
<dd>
|
731
|
+
<p>
|
732
|
+
</p>
|
733
|
+
|
734
|
+
<dt>result_metadata()
|
735
|
+
<dd>
|
736
|
+
<p>
|
737
|
+
</p>
|
738
|
+
|
739
|
+
<dt>row_seek(offset)
|
740
|
+
<dd>
|
741
|
+
<p>
|
742
|
+
</p>
|
743
|
+
|
744
|
+
<dt>row_tell()
|
745
|
+
<dd>
|
746
|
+
<p>
|
747
|
+
</p>
|
748
|
+
|
749
|
+
<dt>sqlstate()
|
750
|
+
<dd>
|
751
|
+
<p>
|
752
|
+
</p>
|
753
|
+
</dl>
|
754
|
+
|
755
|
+
<h3>ITERATOR</h3>
|
756
|
+
<dl>
|
757
|
+
<dt>each() {|x| ...}
|
758
|
+
<dd>
|
759
|
+
<p>
|
760
|
+
</p>
|
761
|
+
</dl>
|
762
|
+
|
763
|
+
<h2>Mysql::Time class</h2>
|
764
|
+
<p>
|
765
|
+
</p>
|
766
|
+
|
767
|
+
<h3>CLASS METHODS</h3>
|
768
|
+
<dl>
|
769
|
+
<dt>new(year=0,month=0,day=0,hour=0,minute=0,second=0,neg=false,second_part=0)
|
770
|
+
<dd>
|
771
|
+
<p>
|
772
|
+
</p>
|
773
|
+
</dl>
|
774
|
+
|
775
|
+
<h3>OBJECT VARIABLES</h3>
|
776
|
+
<dl>
|
777
|
+
<dt>year
|
778
|
+
<dd>
|
779
|
+
|
780
|
+
<dt>month
|
781
|
+
<dd>
|
782
|
+
|
783
|
+
<dt>day
|
784
|
+
<dd>
|
785
|
+
|
786
|
+
<dt>hour
|
787
|
+
<dd>
|
788
|
+
|
789
|
+
<dt>minute
|
790
|
+
<dd>
|
791
|
+
|
792
|
+
<dt>second
|
793
|
+
<dd>
|
794
|
+
|
795
|
+
<dt>neg
|
796
|
+
<dd>
|
797
|
+
|
798
|
+
<dt>second_part
|
799
|
+
<dd>
|
800
|
+
</dl>
|
801
|
+
|
802
|
+
<h2>Mysql::Error class</h2>
|
803
|
+
|
804
|
+
<h3>OBJECT VARIABLES(read only)</h3>
|
805
|
+
<dl>
|
806
|
+
<dt>error
|
807
|
+
<dd>eror message
|
808
|
+
<dt>errno
|
809
|
+
<dd>error number
|
810
|
+
</dl>
|
811
|
+
|
812
|
+
<h2>History</h2>
|
813
|
+
<dl>
|
814
|
+
<dt>2006-06-04
|
815
|
+
<dd>
|
816
|
+
version 2.7.1
|
817
|
+
<ul>
|
818
|
+
<li>change free() to xfree(). To avoid crash on Windows. (Thanks Tobias Grimm)
|
819
|
+
</ul>
|
820
|
+
|
821
|
+
<dt>2005-08-22
|
822
|
+
<dd>
|
823
|
+
version 2.7
|
824
|
+
<ul>
|
825
|
+
<li>add constants for Mysql#options: Mysql::OPT_GUESS_CONNECTION, Mysql::OPT_USE_EMBEDDED_CONNECTION, Mysql::OPT_USE_REMOTE_CONNECTION, Mysql::SET_CLIENT_IP
|
826
|
+
<li>test.rb: for 4.0.x, 5.0.x
|
827
|
+
</ul>
|
828
|
+
|
829
|
+
<dt>2005-08-16
|
830
|
+
<dd>
|
831
|
+
version 2.7-beta3
|
832
|
+
<ul>
|
833
|
+
<li>add Mysql::Stmt#bind_result
|
834
|
+
</ul>
|
835
|
+
|
836
|
+
<dt>2005-08-02
|
837
|
+
<dd>
|
838
|
+
version 2.7-beta2
|
839
|
+
<ul>
|
840
|
+
<li>BUG: mysql.c.in: fetch_hash: nil value doesn't exist in hash. (Thanks Stefan Kaes)
|
841
|
+
<li>add constant Mysql::VERSION.
|
842
|
+
<li>add Mysql#prepare
|
843
|
+
</ul>
|
844
|
+
|
845
|
+
<dt>2005-07-24
|
846
|
+
<dd>
|
847
|
+
version 2.7-beta
|
848
|
+
<ul>
|
849
|
+
<li>add Mysql#stmt_init method
|
850
|
+
<li>add Mysql::Stmt, Mysql::Time, Mysql::RowOffset class
|
851
|
+
<li>add Mysql::Error#sqlstate method
|
852
|
+
<li>change offset value to Mysql::RowOffset object that is used by Mysql::Result#row_seek,row_tell
|
853
|
+
</ul>
|
854
|
+
|
855
|
+
<dt>2005-07-31
|
856
|
+
<dd>
|
857
|
+
version 2.6.3
|
858
|
+
<ul>
|
859
|
+
<li>add constant Mysql::VERSION.
|
860
|
+
</ul>
|
861
|
+
|
862
|
+
<dt>2005-07-26
|
863
|
+
<dd>
|
864
|
+
version 2.6.2
|
865
|
+
<ul>
|
866
|
+
<li>BUG: mysql.c.in: fetch_hash: nil value doesn't exist in hash. (Thanks Stefan Kaes)
|
867
|
+
</ul>
|
868
|
+
|
869
|
+
<dt>2005-06-28
|
870
|
+
<dd>
|
871
|
+
version 2.6.1
|
872
|
+
<ul>
|
873
|
+
<li>mysql.c.in: fix to compile error on MacOSX.
|
874
|
+
</ul>
|
875
|
+
|
876
|
+
<dt>2005-04-25
|
877
|
+
<dd>
|
878
|
+
version 2.6
|
879
|
+
<ul>
|
880
|
+
<li>add constants for Mysql#option():
|
881
|
+
Mysql::OPT_PROTOCOL, Mysql::OPT_READ_TIMEOUT,
|
882
|
+
Mysql::OPT_WRITE_TIMEOUT, Mysql::SET_CHARSET_DIR,
|
883
|
+
Mysql::SET_CHARSET_NAME, Mysql::SHARED_MEMORY_BASE_NAME,
|
884
|
+
Mysql::SECURE_AUTH
|
885
|
+
<li>add methods: Mysql#more_results?(), Mysql#next_result(),
|
886
|
+
Mysql#set_server_option(), Mysql#sqlstate()
|
887
|
+
<li>add constants for Mysql#connect():
|
888
|
+
Mysql::CLIENT_MULTI_STATEMENTS, Mysql::CLIENT_MULTI_RESULTS
|
889
|
+
<li>add constants for Mysql#set_server_option():
|
890
|
+
Mysql::OPTION_MULTI_STATEMENTS_ON,
|
891
|
+
Mysql::OPTION_MULTI_STATEMENTS_OFF
|
892
|
+
<li>add Mysql#query() with block
|
893
|
+
<li>add Mysql#reconnect(), Mysql#reconnect=()
|
894
|
+
<li>When connection was closed, it don't try to reconnect by default.
|
895
|
+
</ul>
|
896
|
+
|
897
|
+
<dt>2005-02-12
|
898
|
+
<dd>
|
899
|
+
version 2.5.2
|
900
|
+
<ul>
|
901
|
+
<li>BUG: Mysql#connect make object to not close. (Thanks Andres Salomon)
|
902
|
+
</ul>
|
903
|
+
|
904
|
+
<dt>2004-09-20
|
905
|
+
<dd>
|
906
|
+
version 2.5.1
|
907
|
+
<ul>
|
908
|
+
<li>add Mysql#set_ssl().
|
909
|
+
</ul>
|
910
|
+
|
911
|
+
<dt>2004-08-31
|
912
|
+
<dd>
|
913
|
+
version 2.5
|
914
|
+
<ul>
|
915
|
+
<li>correspond to MySQL 4.1.x.
|
916
|
+
<li>change MysqlRes, MysqlField, MysqlError to Mysql::Result, Mysql::Field, Mysql::Error.
|
917
|
+
<li>add Mysql.client_version(), Mysql.get_client_version(),
|
918
|
+
Mysql#client_version(), Mysql#get_client_version(),
|
919
|
+
Mysql#server_version(), Mysql#get_server_version(),
|
920
|
+
Mysql#warning_count(), Mysql#commit(), Mysql#rollback(),
|
921
|
+
Mysql#autocommit().
|
922
|
+
<li>add Mysql::Field#is_not_null?(), Mysql::Field#is_pri_key?(),
|
923
|
+
Mysql::Field#is_num?().
|
924
|
+
<li>add MysqlField::TYPE_VAR_STRING.
|
925
|
+
</ul>
|
926
|
+
|
927
|
+
<dt>2003-08-10
|
928
|
+
<dd>
|
929
|
+
version 2.4.5
|
930
|
+
<ul>
|
931
|
+
<li>extconf.rb: correspond to MySQL 4.1.
|
932
|
+
<li>mysql.c.in: correspond to Ruby 1.8.
|
933
|
+
</ul>
|
934
|
+
|
935
|
+
<dt>2003-02-23
|
936
|
+
<dd>
|
937
|
+
version 2.4.4a
|
938
|
+
<ul>
|
939
|
+
<li>make extconf.rb to correspond to Ruby 1.8.0
|
940
|
+
</ul>
|
941
|
+
|
942
|
+
<dt>2003-01-29
|
943
|
+
<dd>
|
944
|
+
version 2.4.4
|
945
|
+
<ul>
|
946
|
+
<li>add Mysql::OPT_LOCAL_INFILE.
|
947
|
+
<li>add --with-mysql-config option to extconf.rb.
|
948
|
+
<li>extconf.rb automatically detect typical library.
|
949
|
+
</ul>
|
950
|
+
|
951
|
+
<dt>2003-01-05
|
952
|
+
<dd>
|
953
|
+
version 2.4.3c
|
954
|
+
<ul>
|
955
|
+
<li>modified English README. Thanks to Paul DuBois.
|
956
|
+
</ul>
|
957
|
+
|
958
|
+
<dt>2002-12-24
|
959
|
+
<dd>
|
960
|
+
version 2.4.3b
|
961
|
+
<ul>
|
962
|
+
<li>make extconf.rb to correspond to Ruby 1.6.8.
|
963
|
+
</ul>
|
964
|
+
|
965
|
+
<dt>2002-11-07
|
966
|
+
<dd>
|
967
|
+
version 2.4.3a
|
968
|
+
<ul>
|
969
|
+
<li>fix bug duplicating constant.
|
970
|
+
</ul>
|
971
|
+
|
972
|
+
<dt>2002-09-10
|
973
|
+
<dd>
|
974
|
+
version 2.4.3
|
975
|
+
<ul>
|
976
|
+
<li>for error number with prefix ER_ .
|
977
|
+
<li>get error constant from errmsg.h and mysqld_error.h automatically.
|
978
|
+
</ul>
|
979
|
+
|
980
|
+
<dt>2002-01-07
|
981
|
+
<dd>
|
982
|
+
version 2.4.2
|
983
|
+
<ul>
|
984
|
+
<li>for MySQL 4.0.
|
985
|
+
<li>change `uint' to `unsigned int' (for mswin).
|
986
|
+
</ul>
|
987
|
+
|
988
|
+
<dt>2001-12-02
|
989
|
+
<dd>
|
990
|
+
version 2.4.1
|
991
|
+
<ul>
|
992
|
+
<li>remove `extern' (for Cygiwn).
|
993
|
+
<li>change option of extconf.rb.
|
994
|
+
</ul>
|
995
|
+
|
996
|
+
<dt>2001-10-12
|
997
|
+
<dd>
|
998
|
+
version 2.4.0
|
999
|
+
<ul>
|
1000
|
+
<li>for Ruby 1.7.
|
1001
|
+
<li>add Mysql::debug(), Mysql#change_user(), Mysql#character_set_name(), Mysql#dump_debug_info().
|
1002
|
+
</ul>
|
1003
|
+
</dl>
|
1004
|
+
|
1005
|
+
<h2>Author</h2>
|
1006
|
+
<p>
|
1007
|
+
e-mail: TOMITA Masahiro <a href="mailto:tommy@tmtm.org">tommy@tmtm.org</a>
|
1008
|
+
<a href="http://tmtm.org">http://tmtm.org</a>
|
1009
|
+
</p>
|
1010
|
+
<hr>
|
1011
|
+
<address><a href="mailto:tommy@tmtm.org">TOMITA Masahiro</a></address>
|
1012
|
+
<!-- Created: Sun Aug 29 11:52:09 JST 2004 -->
|
1013
|
+
<!-- hhmts start -->
|
1014
|
+
Last modified: Sun Jun 4 23:39:34 JST 2006
|
1015
|
+
<!-- hhmts end -->
|
1016
|
+
</body>
|
1017
|
+
</html>
|