my %Q = CGI::Vars(); ... $id_cust = AddCusomer($Q{login}, $Q{pass}, $Q{name}, $Q{email}, ...) if $Q{pass} eq $Q{confirmpass}; ... sub AddCustomer { my ($login, $pass, $name, $email, ...) = @_; $dbh->do("INSERT INTO Customer SET login=?, pass=?, name=?, email=?, ...", undef, $login, $pass, $name, $email, ...) or return; $dbh->selectrow_array("SELECT LAST_INSERT_ID()"); } #### my %Q = CGI::Vars(); ... $id_cust=$dbh->Insert("Customer", \%Q) if $Q{pass} eq $Q{confirmpass}; #### # CREATE TABLE Customer ( # id_cust int auto_increment primary key, # login varchar(255) not null, # pass varchar(255) not null, # name varchar(255) not null, # email varchar(255) not null, # ) ; # INSERT INTO Customer SET login='powerman', pass='11111', # name='Alex', email='root@localhost' ; # SELECT LAST_INSERT_ID() ; %Q = ( login => "powerman", pass => "11111", name => "Alex", email => "root@localhost", BADKEY => "QWEQWE", ); $id_cust = $dbh->Insert("Customer", \%Q); # UPDATE Customer SET pass='22222', name='Alex Efros' # WHERE id_cust=1 ; %Q = ( id_cust => 1, pass => '22222', name => 'Alex Efros', ); $dbh->Update("Customer", \%Q); # REPLACE INTO Customer SET id_cust=1, pass='33333' ; $dbh->Replace("Customer", {id_cust=>1, pass=>'33333'}); # DELETE FROM Customer WHERE login='powerman' AND pass='33333' ; $dbh->Delete("Customer", {login=>"powerman", pass=>"33333"}); # SELECT id_cust FROM Customer WHERE login='powerman' AND pass='33333' ; $id_cust = $dbh->ID("Customer", {login=>'powerman', pass=>'33333'}) # SELECT count(*) as __count FROM Customer $count = $dbh->Count("Customer"); # SELECT * FROM Customer @all_customers = $dbh->Select("Customer"); # SELECT * FROM Customer WHERE id_cust=1 ; $Cust = $dbh->Select("Customer", {id_cust=>1}); #### # CREATE TABLE Cust ( # id_cust int auto_increment primary key, # id_country int, # age int, # join_date datetime, # _balance decimal(8,2), # ); # CREATE TABLE SelectedGoods ( # id_sg int auto_increment primary key, # id_cust int, # id_goods int, # ); # CREATE TABLE Goods ( # id_goods int auto_increment primary key, # goods varchar(255) not null, # cost decimal(8,2) not null, # ); # CREATE TABLE Country ( # id_country int auto_increment primary key, # country varchar(255) not null, # ); # SELECT # Cust.id_cust, Cust.id_country, Cust.age, # Cust.join_date, Cust._balance, # SelectedGoods.id_sg, SelectedGoods.id_cust, # SelectedGoods.id_goods, # Goods.goods, Goods.cost, # Country.country # FROM # Cust # INNER JOIN SelectedGoods ON (Cust.id_cust = SelectedGoods.id_cust) # INNER JOIN Goods ON (SelectedGoods.id_goods = Goods.id_goods) # INNER JOIN Country ON (Cust.id_country = Country.id_country) # WHERE # Country.country = 'Ukraine' AND # Cust.age >= 25 AND # Cust.join_date >= DATE_ADD(NOW(), INTERVAL -1 DAY) AND # Cust._balance > 5.50 AND # Goods.goods IN ('Monitor LG','CDROM 52x') # ORDER BY # Cust._balance DESC, # Cust.age ASC ; %Q = ( country => 'Ukraine', age__ge => 25, join_date__date_ge => "-1 DAY", _balance__gt => 5.50, goods => ["Monitor LG", "CDROM 52x"], -order => ["_balance DESC", "age"], ); @search_result = $dbh->Select(["Customer", "SelectedGoods", "Goods", "Country"], \%Q); #### $dbh->Update("Customer", \%Q); #### %Q = CGI::Vars(); delete $Q{$_} for grep {m/^_/} keys %Q; #### $Q{_balance} = $Q{Set_balance} if $Admin and $Q{Set_balance}; $dbh->Insert("Customer", \%Q); #### $Q{_balance} = $Q{Set_balance} if $Admin and $Q{Set_balance}; $dbh->Insert("Customer", {%Q, id_cust=>$CustID});