[Dbix-class] mysql insert seems wrong

Johannes Rumpf jrumpf at web-dreamer.de
Fri Feb 2 11:35:58 GMT 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi all,

i'm new to this module and actual a bit confused about a errormessage. I
hope you can help me out here:

Very Simple example using a XAMPP- DB.
Here is my code:
- --------
package mydb::Schema;
use base qw/DBIx::Class::Schema/;

#__PACKAGE__->load_components (qw/ Core /);
__PACKAGE__->load_classes ();
1;
- --------
package mydb::Schema::cds;
use base qw/DBIx::Class/;

@columns = qw/ interpret id jahr titel /;

sub get_columns(){
return @columns;
}

__PACKAGE__->load_components (qw/PK::Auto Core /);

__PACKAGE__->table ('cds');

__PACKAGE__->add_columns (@columns);

#_PAKAGE__->set_primary_key ( qw/ id /);
1;

- --------
use mydb::Schema;
use strict;


my $db = 'cdcol';
my $user= 'root';
my $passwort = '';
my $schema = mydb::Schema->connect("dbi:mysql:$db", $user, $passwort);

$schema->storage->debug(1);

my $cds = $schema->resultset('cds');

my $new_cds = $schema->resultset('cds')->new({titel => 'god bey'});
print $new_cds->insert;

my @all = $cds->all();
while (my $rsc = $cds->next){

my $tmp;
foreach (mydb::Schema::cds->get_columns){
	$tmp = $rsc->get_column($_);
	print "$tmp	";
}
print "\n";
}
my @ja = mydb::Schema::cds->get_columns();

- ----

Thats a output:

INSERT INTO cds (interpret, jahr) VALUES (?, ?): 'id', 'titel'
SELECT me.interpret, me.id, me.jahr, me.titel FROM cds me:
SELECT me.interpret, me.id, me.jahr, me.titel FROM cds me:
mydb::Schema::cds=HASH(0x1e9d3fc)Ryuichi Sakamoto       1       1990
Beauty

Groove Armada   4       2001    Goodbye Country (Hello Nightclub)
Bran Van 3000   5       1997    Glee
id      52      0
id      51      0
SELECT COUNT( * ) FROM cds me:
5

- ---

As you may see the INSERT doesn't fit what i am expecting it to do.

I tried populate as well - but with the same result. Also i tried
several calling variants but i'm stucked.

Yours,
 Johannes Rumpf

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.0 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFwyIenmAbbUgFSFgRAjF3AJ48aL+G5MWjiUx+V8sHkJXm6pMxQQCeMOLP
+mUvBaNCgqruO7hxsVhm5e0=
=RokP
-----END PGP SIGNATURE-----



More information about the Dbix-class mailing list