[Dbix-class] not able to list any records from database

Rajeev Prasad rp.neuli at yahoo.com
Thu Sep 1 22:11:12 GMT 2011


thx Marc, by going to that link i was able to list all and specific user:
=A0
=A0
I am still trying to figure how to list all users starting with letter 't'.=
..
=A0
=A0
=A0
#list all users
print "all-users\n";
$users_rs =3D $schema->resultset('Testdbuser')->search;
while ($user =3D $users_rs->next ()){
=A0print "user is: " . $user->get_column("userid") . " password is: " . $us=
er->get_column("password") . "\n";
=A0};
=A0
#list specific user, with modified column names,
print "\nspecific\n";
$users_rs =3D $schema->resultset('Testdbuser')->search(
=A0=A0=A0 { 'userid' =3D> "test12" },=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 ## WHERE
=A0=A0=A0 { =

=A0=A0=A0=A0=A0 select=A0=A0 =3D> [ qw/userid password/ ],=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 ## SELECT
=A0=A0=A0=A0=A0 as=A0=A0=A0=A0=A0=A0 =3D> [ qw/uid pass/ ],
=A0=A0=A0 }
=A0 );
while ($user =3D $users_rs->next ()){
=A0print "user is: " . $user->get_column("uid") . " password is: " . $user-=
>get_column("pass") . "\n";
=A0};

=A0
=A0
=A0

From: Marc Logghe <logghe.marc at gmail.com>
To: Rajeev Prasad <rp.neuli at yahoo.com>; DBIx::Class user and developer list=
 <dbix-class at lists.scsys.co.uk>
Sent: Thursday, September 1, 2011 4:50 PM
Subject: Re: [Dbix-class] not able to list any records from database





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:l=
ocalhost:3306", 'root', 'mysql5');
>$users_rs =3D $schema->resultset('Testdbuser')->search(
>=A0=A0=A0 { 'userid' =3D> 'test' },=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 ## WHERE
>=A0=A0=A0 { =

>=A0=A0=A0=A0=A0 select=A0=A0 =3D> [ qw/userid password/ ],=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 ## SELECT
>=A0=A0=A0=A0=A0 as=A0=A0=A0=A0=A0=A0 =3D> [ qw/uid pass/ ],
>=A0=A0=A0 }
>=A0 );
>=A0 =

>while ($user =3D $users_rs->next ()){
>=A0print "user is:" . $user->uid . "\n";
>=A0};
>
>
>
>
>

=A0Have a look at=A0http://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/e53=
8a1dc/attachment.htm


More information about the DBIx-Class mailing list