Leser: 1
|< 1 2 >| | 11 Einträge, 2 Seiten |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/usr/bin/perl
use strict;
use warnings;
use SQL::Abstract;
my $sql = SQL::Abstract->new;
my @fields = ('id', 'name');
my %where = (id => 15);
my($sth, @bind) = $sql->select('users', \@fields, \%where);
print $sth,"\n";
my($sth, @bind) = $sql->select('users LEFT JOIN x on(id)', \@fields, \%where);
my($sth, @bind) = $sql->select([qw(users x)], \@fields, \%where);
1
2
3
my($sth, @bind) = $sql->select(['users', 'sessions'], \@fields, \%where);
#SELECT users.id, sessions.name FROM users, sessions WHERE ( id = ? )
1 2 3 4 5 6 7 8 9 10
# Utility functions sub _table { my $self = shift; my $tab = shift; if (ref $tab eq 'ARRAY') { return join ', ', map { $self->_quote($_) } @$tab; } else { return $self->_quote($tab); } }
$sql->select($table." LEFT JOIN sessions ON ...", \@fields, \%where);
|< 1 2 >| | 11 Einträge, 2 Seiten |