[prev] [thread] [next] [Date index for 2004/07/20]
Maybe this was a typo, but you need to retrieve the "user" first before you can print it like you did with "node". Or maybe you want to access the "user" via the "node" like: print $node->author->email,"\n"; Jay ----- Original Message ----- From: "Teun van Eijsden" <groups.kasei.com@xxxx.xxxxx.xx> To: <cdbi-talk@xxxxxx.xxxxx.xxx> Sent: Tuesday, July 20, 2004 3:45 AM Subject: create after create or retrievemore mus doesnt work Hi all, When i create a row in one table and then in another, it doesn't fill out all the values of the second create, only the primary key. Below you'll find a listing of everything relevant (separated bij bold headers). Any pointers would be appreciated. Teun van Eijsden The Netherlands MySQL DDL: create table nodes (nid VARCHAR(255) PRIMARY KEY, author VARCHAR(255), date TIMESTAMP, content LONGBLOB, public TINYINT); create table access (id INT AUTO_INCREMENT PRIMARY KEY, nid VARCHAR(255), uid VARCHAR(255), subscription TINYINT); create table users (uid VARCHAR(255) PRIMARY KEY, email VARCHAR(255), employee TINYINT); perl script: #!/cadappl/bin/perl -w use strict; use Class::DBI; DBI->trace(1 => "/tmp/logfile"); # trace all the SQL code package Doc::DBI; use base 'Class::DBI'; Doc::DBI->connection('DBI:mysql:database=hivedoc;host=webservername.com', 'hive', '*****'); package Doc::Access; use base 'Doc::DBI'; Doc::Access->table('access'); Doc::Access->columns(All => qw/id nid uid subscription/); Doc::Access->has_a(nid => 'Doc::Node'); package Doc::Node; use base 'Doc::DBI'; Doc::Node->table('nodes'); Doc::Node->columns(All => qw/nid author date content public/); Doc::Node->has_a(author => 'Doc::User'); Doc::Node->has_many(access => 'Doc::Access'); package Doc::User; use base 'Doc::DBI'; Doc::User->table('users'); Doc::User->columns(All => qw/uid email employee/); package main; #my $node = Doc::Node->create({nid => "HomePage", author => "eijsdent", content => 'Silicon Hive rules', public => 1}); my $node = Doc::Node->retrieve("HomePage"); print 'Author: .'; print $node->author; print ".\n"; my $user = Doc::User->create({'uid' => 'eijsdent', 'email' => 'jaap@xxxxx.xx', 'employee' => 1}); #$user->update; print 'Email: .'; print $user->email; print ".\n"; Output: ./music.pl Author: .eijsdent. Use of uninitialized value in print at ./music.pl line 42. Email: .. in MySQL database: select * from users; +----------+-------+----------+ | uid | email | employee | +----------+-------+----------+ | eijsdent | NULL | NULL | +----------+-------+----------+ 1 row in set (0.00 sec) SQL Trace Log: DBI 1.43-nothread default trace level set to 0x0/1 (pid 22839) -> DBI->connect_cached(DBI:mysql:database=hivedoc;host=webdb.natlab.research.ph ilips.com, hive, ****) -> DBI->install_driver(mysql) for linux perl=5.006001 pid=22839 ruid=3982 euid=3982 install_driver: DBD::mysql version 2.1026 loaded from /cadappl/perl/5.6.1/lib/site_perl/5.6.1/i686-linux/DBD/mysql.pm <- install_driver= DBI::dr=HASH(0x81dab2c) <- connect_cached('database=hivedoc;host=webdb.natlab.research.philips.com' 'hive' ...)= DBI::db=HASH(0x830f88c) at DBI.pm line 595 <- STORE('RootClass' 'DBIx::ContextualFetch')= 1 at DBI.pm line 628 _set_isa([DBIx::ContextualFetch]) DBIx::ContextualFetch::db::ISA skipped (already set to DBI::db) DBIx::ContextualFetch::st::ISA skipped (already set to DBI::st) <- STORE('RaiseError' 1)= 1 at DBI.pm line 642 <- STORE('PrintError' 0)= 1 at DBI.pm line 642 <- STORE('AutoCommit' 1)= 1 at DBI.pm line 642 T <- STORE('Taint' 1)= 1 at DBI.pm line 645 T <- FETCH('Taint')= 1 at DBI.pm line 645 T <- STORE('Username' 'hive')= 1 at DBI.pm line 645 T <> FETCH('Username')= 'hive' ('Username' from cache) at DBI.pm line 645 T <- STORE('FetchHashKeyName' 'NAME_lc')= 1 at DBI.pm line 645 T <> FETCH('FetchHashKeyName')= 'NAME_lc' ('FetchHashKeyName' from cache) at DBI.pm line 645 T <- STORE('ShowErrorStatement' 1)= 1 at DBI.pm line 645 T <- FETCH('ShowErrorStatement')= 1 at DBI.pm line 645 T <- STORE('dbi_connect_method' 'connect_cached')= 1 at DBI.pm line 645 T <> FETCH('dbi_connect_method')= 'connect_cached' ('dbi_connect_method' from cache) at DBI.pm line 645 T <- STORE('ChopBlanks' 1)= 1 at DBI.pm line 645 T <- FETCH('ChopBlanks')= 1 at DBI.pm line 645 <- connect= DBIx::ContextualFetch::db=HASH(0x830f88c) T <- STORE('dbi_connect_closure' CODE(0x830f934))= 1 at DBI.pm line 665 T <- prepare_cached('SELECT nid FROM nodes WHERE nid = ? ')= ( DBIx::ContextualFetch::st=HASH(0x82e7a90) ) [1 items] at DBI.pm line 391 T <- FETCH('Active')= '' at DBI.pm line 1124 T <- FETCH('Taint')= 1 at ContextualFetch.pm line 49 <- STORE('Taint' 0)= 1 at ContextualFetch.pm line 50 <- execute('HomePage')= 1 at ContextualFetch.pm line 51 T <- STORE('Taint' 1)= 1 at ContextualFetch.pm line 52 T <- FETCH('NAME_lc')= [ 'nid' ] at DBI.pm line 1125 T <- bind_columns(SCALAR(0x831d50c))= 1 at DBI.pm line 1125 T <- fetchrow_arrayref= [ 'HomePage' ] row1 at ContextualFetch.pm line 59 T <- fetchrow_arrayref= undef row1 at ContextualFetch.pm line 59 T <- FETCH('Active')= 1 at DBI.pm line 316 T <- ping= 1 at DBI.pm line 316 T <- prepare_cached('SELECT content, author, date, public FROM nodes WHERE nid=? ')= DBIx::ContextualFetch::st=HASH(0x831d62c) at DBI.pm line 391 T <- FETCH('Taint')= 1 at ContextualFetch.pm line 49 <- STORE('Taint' 0)= 1 at ContextualFetch.pm line 50 <- execute('HomePage')= 1 at ContextualFetch.pm line 51 T <- STORE('Taint' 1)= 1 at ContextualFetch.pm line 52 T <- fetchrow_array= ( 'Silicon Hive rules' 'eijsdent' '20040720101349' '1' ) [4 items] row1 at ContextualFetch.pm line 87 T <- finish= 1 at ContextualFetch.pm line 88 T <- FETCH('Active')= 1 at DBI.pm line 316 T <- ping= 1 at DBI.pm line 316 T <- prepare_cached('INSERT INTO users (uid) VALUES (?) ')= DBIx::ContextualFetch::st=HASH(0x832747c) at DBI.pm line 391 T <- FETCH('Taint')= 1 at ContextualFetch.pm line 49 <- STORE('Taint' 0)= 1 at ContextualFetch.pm line 50 <- execute('eijsdent')= 1 at ContextualFetch.pm line 51 T <- STORE('Taint' 1)= 1 at ContextualFetch.pm line 52 T <- FETCH('Active')= 1 at DBI.pm line 316 T <- ping= 1 at DBI.pm line 316 T <- prepare_cached('SELECT employee, email FROM users WHERE uid=? ')= DBIx::ContextualFetch::st=HASH(0x83277ac) at DBI.pm line 391 T <- FETCH('Taint')= 1 at ContextualFetch.pm line 49 <- STORE('Taint' 0)= 1 at ContextualFetch.pm line 50 <- execute('eijsdent')= 1 at ContextualFetch.pm line 51 T <- STORE('Taint' 1)= 1 at ContextualFetch.pm line 52 T <- fetchrow_array= ( undef undef ) [2 items] row1 at ContextualFetch.pm line 87 T <- finish= 1 at ContextualFetch.pm line 88 <- disconnect_all= '' at DBI.pm line 674 !T <- DESTROY(DBIx::ContextualFetch::st=HASH(0x83277ac))= undef during global destruction !T <- DESTROY(DBIx::ContextualFetch::st=HASH(0x832747c))= undef during global destruction !T <- DESTROY(DBIx::ContextualFetch::st=HASH(0x831d62c))= undef during global destruction !T <- DESTROY(DBIx::ContextualFetch::st=HASH(0x82e7a90))= undef during global destruction !T <- DESTROY(DBIx::ContextualFetch::db=HASH(0x830f88c))= undef during global destruction ! <- DESTROY(DBI::dr=HASH(0x81dab2c))= (not implemented) during global destruction
create after create or retrievemore mus doesnt work
|
Re: create after create or retrievemore mus doesnt work
|
Generated at 11:34 on 01 Dec 2004 by mariachi v0.52