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