[Dbix-class] not able to list any records from database
Rob Kinyon
rob.kinyon at gmail.com
Thu Sep 1 22:43:46 GMT 2011
userid => { -like => 't% }
--
Rob Kinyon (Mobile)
This message may contain confidential information. Please delete it if you are not the intended recipient.
On Sep 1, 2011, at 18:11, Rajeev Prasad <rp.neuli at yahoo.com> wrote:
> thx Marc, by going to that link i was able to list all and specific user:
>
>
> I am still trying to figure how to list all users starting with letter 't'...
>
>
>
> #list all users
> print "all-users\n";
> $users_rs = $schema->resultset('Testdbuser')->search;
> while ($user = $users_rs->next ()){
> print "user is: " . $user->get_column("userid") . " password is: " . $user->get_column("password") . "\n";
> };
>
> #list specific user, with modified column names,
> print "\nspecific\n";
> $users_rs = $schema->resultset('Testdbuser')->search(
> { 'userid' => "test12" }, ## WHERE
> {
> select => [ qw/userid password/ ], ## SELECT
> as => [ qw/uid pass/ ],
> }
> );
> while ($user = $users_rs->next ()){
> print "user is: " . $user->get_column("uid") . " password is: " . $user->get_column("pass") . "\n";
> };
>
>
>
>
> 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 = Mysqltestdb::Schema->connect("dbi:mysql:dbname=mysqltestdb:localhost:3306", 'root', 'mysql5');
> $users_rs = $schema->resultset('Testdbuser')->search(
> { 'userid' => 'test' }, ## WHERE
> {
> select => [ qw/userid password/ ], ## SELECT
> as => [ qw/uid pass/ ],
> }
> );
>
> while ($user = $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
>
>
> _______________________________________________
> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20110901/304b96a8/attachment.htm
More information about the DBIx-Class
mailing list