Beefy Boxes and Bandwidth Generously Provided by pair Networks Joe
No such thing as a small change
 
PerlMonks  

Re: How to structure applications using a RDBMS

by gav^ (Curate)
on Jul 19, 2002 at 01:10 UTC ( #183101=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
       My::User->set_sql(
          'getUsers', 'select * from users', 'Main'
       );
    
  2. or download this
       my $sth = My::User->sql_getUsers;
       $sth->execute();
       # etc
    
  3. or download this
        $sth->execute([qw/value1 value2/], [\my $res1]);
        my %hash = $sth->fetch_hash;
    
  4. or download this
    package User;
    use base 'Class::DBI';
    
    ...
    User->columns('All', qw/id name password/);
    User->coumns('Primary', 'id');
    User->set_db('Main', 'dbi:mysql', 'gav', 'perlmonks');
    
  5. or download this
        my $user1 = User->new({ name => 'gav', password => 'monk' });
        my $user2 = User->retrieve(1023);
        printf "Id: %d, Name: %s, Pass %s\n", $user2->id, $user2->name, 
            $user2->password;
    
  6. or download this
        my $user = User->search(name => 'gav');
        if ($user && ($user = $user->next) && $user->password eq 'monk') {
            print "Welcome gav^!\n";
        } else {
            print "Schoo!\n";
        }
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://183101]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (9)
As of 2014-04-20 15:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (485 votes), past polls