[Dbix-class] not able to list any records from database
Marc Logghe
logghe.marc at gmail.com
Thu Sep 1 21:50:52 GMT 2011
On Thu, Sep 1, 2011 at 11:40 PM, Rajeev Prasad <rp.neuli at yahoo.com> wrote:
> follwoing code is not printing anything...???? can anyone help plz?
>
>
> #!/usr/bin/perl
> use strict;
> use warnings;
> use lib '../testdb';
> use Mysqltestdb::Schema;
> my ($schema, $user, $users_rs);
> my (@newusers, @oldusers);
> $schema =3D
> Mysqltestdb::Schema->connect("dbi:mysql:dbname=3Dmysqltestdb:localhost:33=
06",
> 'root', 'mysql5');
> $users_rs =3D $schema->resultset('Testdbuser')->search(
> { 'userid' =3D> 'test' }, ## WHERE
> {
> select =3D> [ qw/userid password/ ], ## SELECT
> as =3D> [ qw/uid pass/ ],
> }
> );
>
> while ($user =3D $users_rs->next ()){
> print "user is:" . $user->uid . "\n";
> };
>
>
>
>
Have a look at
http://search.cpan.org/~abraxxa/DBIx-Class-0.08195/lib/DBIx/Class/ResultSet=
.pm#as
$user->get_column('uid') or the normal accessor $user->userid should work
(at least when a matching row is available)
cheers,
Marc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20110901/f2b=
b149f/attachment.htm
More information about the DBIx-Class
mailing list