sam-mysql-ruby 2.8.1

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