# $Id: README,v 1.1 1998/11/29 13:58:46 tommy Exp $

MySQL Ruby Module ver2.0.1

This is Ruby API of MySQL. This have functions as same as MySQL C API.

To be compatibe with ver1.0, do require 'mysql-compat'.

[Require]

* MySQL 3.22.10
* Ruby 1.1.c7
* gcc 2.8.1

[Installation]

Make sure that $CFLAGS, $LDFLAGS, $libs in extconf.rb are valid, and do:

	% ruby extconf.rb
	% make
	% make install
	% cp mysql.rb /usr/local/lib/ruby		# optional
	% cp mysql-compat.rb /usr/local/lib/ruby	# optional

[Usage]

The method name is same as C API function excluding 'mysql_' prefix.
The usage of method is also same as C API function, so see MySQL manual
for more detail.

When error is occured in the method, MysqlError exception is raised.

The method returns TRUE if the method return nothing.

require "mysql"
	load mysql module.

require "mysql-compat"
	load mysql module for compatibilty with ver1.0.

[Mysql class]

  This is class to handle MySQL.

  Class Methods

    real_connect(host=nil, user=nil, passwd=nil, db=nil, port=nil, sock=nil, flag=nil)
	connect() and new() are synonym.
    escape_string(str)
	quote() is synonym.
    get_client_info()
	client_info() is synonym.

 Object Methods

    affected_rows()
    close()
    create_db(db)
    drop_db(db)
    errno()
    error()
    get_host_info()
	host_info() is synonym.
    get_proto_info()
	proto_info() is synonym.
    get_server_info()
	server_info() is synonym.
    info()
    insert_id()
    kill(id)
    list_dbs(db=nil)
    list_fields(table, field=nil)
    list_processes()
    list_tables(table=nil)
    ping()
    query(q)
	If query return result, query() automatically execute
	store_result() and return MysqlRes object.
	If query_with_result is false, store_result() isn't done.
    reload()
    select_db(db)
    shutdown()
    stat()
    store_result()
    thread_id()
    use_result()

 Object Variable

    query_with_result
	See query(), default value is true.

[MysqlRes class]

  This is class to indicate query's result.

 Class Methods

    data_seek(offset)
    fetch_field()
    fetch_fields()
    fetch_field_direct(fieldnr)
    fetch_lengths()
    fetch_row()
    fetch_hash(with_table=false)
	Return the row formatted hash 'column'=>'value'.
	If with_table is true, the format is 'table.column'=>'value'.
	* required mysql.rb
    field_seek(offset)
    field_tell()
    num_fields()
    num_rows()
    row_seek(offset)
    row_tell()

 Iterator

    each() {|x| do something...}
	Iterate per row. The x is array of column value.
    each_hash(with_table=false) {|x| do something...}
	Iterate per row. The x is hash of 'column'=>'value'.
	If with_table is true, the format is 'table.column'=>'value'.
	* required mysql.rb

[MysqlField class]

  This is class to indicate column field.
  Note that this object is independent from MysqlRes object, so when
  MysqlRes object is free, MysqlField object can be used. But this use
  more memory than C API.

 Object variable (read only)
    name
    table
    def
    type
    length
    max_length
    flags
    decimals

    The constant for 'type' is same as C API excluding 'FILED_' prefix.
    ex.) MysqlField::TYPE_STRING

    The constant for 'flag' is same as C API.
    ex.) MysqlField::BLOB_FLAG

[Author]

  e-mail: TAMITO <tommy@valley.ne.jp>
  http://www.valley.ne.jp/~tommy/
