Walery Studennikov > MySQL-Insert > MySQL::Insert

Download:
MySQL-Insert-0.06.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.06   Source  

NAME ^

MySQL::Insert - extended inserts for MySQL via DBI

SYNOPSIS ^

    # Insert two rows into sample_table using $dbh database handle

    use MySQL::Insert;

    $MySQL::Insert::MAX_ROWS_TO_QUERY = 1000;

    my $inserter = MySQL::Insert->new( $dbh, 'sample_table', [ @field_names ], %param );

    # Param can be:
    # statement = 'INSERT' | 'REPLACE' | 'INSERT IGNORE' (by default)
    # on_duplicate_update = { field_name => field_value, .. } (not used by default)

    # simple insertion
    $inserter->insert_row( { fldname => 'fldvalue1' } );
    $inserter->insert_row( { fldname => 'fldvalue2' } );

    # multirow insertion
    $inserter->insert_row( { fldname => 'fldvalue3' }, { fldname => 'fldvalue4' } );
    $inserter->insert_row( [ 'fldvalue5' ], [ 'fldvalue6' ] } );

    # Insert row into sample_table using $dbh database handle
    # If fldvalue3 is passed as scalar ref then it is not quoted
    # Used to insert MySQL built-in functions like NOW() and NULL values.
    # @field_names must be predefined in case of arrayref row data usage

    $inserter->insert_row( { fldname => \'NOW()' } );

    undef $inserter;

DESCRIPTION ^

Use multiple-row INSERT syntax that include several VALUES lists. (for example INSERT INTO test VALUES ('1',Some data',2234),('2','Some More Data',23444)). EXTENDED INSERT syntax is more efficient of execution many insert queries. It is not compatible with most RDBMSes.

FUNCTIONS / METHODS ^

The following methods are available:

new

Create new MySQL::Insert object

set_fields

Set fields list (by plain list or list reference)

get_fields

Get fields list (or its quantity in scalar context)

insert_row

Schedule row for insertion

AUTHORS ^

Gleb Tumanov <gleb at reg.ru> (original author) Walery Studennikov <despair at cpan.org> (CPAN distribution)

BUGS ^

Please report any bugs or feature requests to bug-mysql-insert at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=MySQL-Insert. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

LICENSE ^

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: