An Introduction to Class::DBI - Primary Keys 22

Portably Generating new primary key values

  • Class DBI lets you work with sequences or AUTO_INCREMENT fields:

        package Customer;
        ...
        # Leave this out for MySQL
        Customer->sequence('customer_id_seq');
        ...
    
        package main;
    
        $customer = Customer->create({
            name    => $name,
            address => $address,
            email   => $email,
        });
    
    • This eases transition from MySQL to Postgres or Oracle

 

YAPC::Canada << Previous | Index | Next >>
Copyright © 2003 Michael Graham