NAME
ShopCard - Create and process ShopCard within MySQL DB
VERSION
ShopCard.pm ver.1.0
DESCRIPTION
ShopCard allows you to create and process ShopCards
SYNOPSIS
There is an example that you may use in your own CGI scripts:
# --- Script begin here ---
use ShopCard;
# NOTE: new() method will create needed DB structure in MySQL (database & tables) if they not exist!
# Please create database before execute this script or DB USER must have privilege to create DBs!
$sid = '54929429823023450234';
$obj = ShopCard->new(database => 'shopdb', user => 'db_user', pass => 'db_pass',
host => 'localhost', id=>$sid);
# OR
# $obj = ShopCard->new(dbh => $mysql_dbh_handler, id=>$sid);
if($obj)
{
$id = $obj->add(product_id=>'8',quantity=>'2',price=>'19',discount=>'0',total=>'38',expire=>'40m','id'=>$sid);
$obj->update_expire('id'=>$sid,'expire'=>'2h');
print "<HR>";
my @res = $obj->find('search'=>'8','sort'=>'EXPIRE','by'=>'PRODUCT_ID','multiple'=>YES,
'partial'=>NO,'reverse'=>NO);
if(scalar(@res))
{
foreach $l (@res)
{
my ($uid,$id,$card_name,$product_id,$quantity,$price,$discount,$total,$currency,$expire) = @$l;
print "UID: $uid<BR>\n";
print "ID: $id<BR>\n";
print "CARD: $card_name<BR>\n";
print "PRODUCT: $product_id<BR>\n";
print "QNT: $quantity<BR>\n";
print "PRICE: $price<BR>\n";
print "DISC: $discount<BR>\n";
print "TOTAL: $total<BR>\n";
print "CURR: $currency<BR>\n";
print "EXPIRE: $expire<BR>\n";
print "<HR>";
}
}
}
else
{
print $ShopCard::error;
}
# --- Script ends here ---
SYNTAX
That is simple function reference:
$object = ShopCard->new(database=>'shopdb', user=>'db_user', pass=>'db_pass', host=>'localhost',
port=>'3306', create=>'Y', checkdb=>'Y', name=>'shop', card_name=>'default',
dbh=>$connect_db_handler, id=>'session_card_id);
Where:
database - is your DB where ShopCard (tables) will be placed. If database not exist module
will try to create one for you, using supplied user and password. [REQUIRED if $dbh empty]
user/pass - is your DB user and password [REQUIRED if $dbh empty]
host - MySQL DB host
port - your MySQL port
create - module will attempt to create DB and/or tables
checkdb - module will try to check DB structure
name - name of shop object
dbh - you can supply already connected database handler instead of database/user/pass/host/port!
card_name - name of shopcard (multilevel name)
id - session/card id [REQUIRED]
AUTHOR
Julian Lishev - Bulgaria, Sofia,
e-mail: julian@proscriptum.com,
www.proscriptum.com