SQL::Abstract使って列を取得する方法
よく忘れて毎回調べるので備忘録。
eval{ my $table = 't_user'; my $sql = SQL::Abstract->new(); my ($stmt , @bind) = $sql->select($table ,['id'], \%params); my $sth = $c->dbh->prepare($stmt); $sth->execute(@bind); my $id = $sth->fetchrow_array; $c->session->set('id' , $id); };
fetchrow_arrayの帰り値は配列。
上記では一要素なので一個しか取ってないけど。