thx.
but when i put search item as 'test12' I get error:
$ get-data-from-db.pl
Use of uninitialized value in concatenation (.) or string at
./get-data-from-db.pl line 23.
user is:
here is the code again, i think i have defined every variable.....
==========================================================
#!/usr/bin/perl
use strict;
use warnings;
use lib '../testdb';
use Mysqltestdb::Schema;
my ($schema, $user, $users_rs, $userid);
my (@newusers, @oldusers);
$schema =
Mysqltestdb::Schema->connect("dbi:mysql:dbname=mysqltestdb:localhost:3306",
'root', 'mysql5');
$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->userid . "\n";
};
=============================================================================
From: Brian E. Lozier <[email protected]>
To: Rajeev Prasad <[email protected]>; DBIx::Class user and developer list
<[email protected]>
Sent: Thursday, September 1, 2011 4:46 PM
Subject: Re: [Dbix-class] not able to list any records from database
On Thu, Sep 1, 2011 at 2:40 PM, Rajeev Prasad <[email protected]> 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"; };
>
>
>database users:
>SQL query: SELECT * FROM `testdbusers` LIMIT 0, 30 ; Rows: 6
>userid
>password
>test12 pass
>user1 pass1
>user2 pass2
>test45 pass
>te1234 pass
>te4567 pass
>
You're searching for userid = 'test' but you have no user 'test' in your
results.{ 'userid' => 'test' },
_______________________________________________
>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/[email protected]
>_______________________________________________
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/[email protected]