Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Writing HASH to a Table

Quote Reply
Writing HASH to a Table
Hi:

I am at wits end....maybe because it's late, maybe because I have a three month old... BUT..

I have created a new table. Fine. I created a .def file for it, fine. I am trying to connect and write to it, and it is not working!

I am connecting using this command:
my $review_db = $DB->table('Review');

That seems to work. But I cannot WRITE to the table "Review". I am using:

$review_db->add ( { Link_ID => $id, Title => $title, Review => $review, User => $username, Post_Date => $today } );

and that did not work. I set up each field like this:

$rec->{Link_ID} = $id;

and then tried

$review_db->insert ($rec);

and that did not work. I am missing something really stupid here, I know it... but what? The syntax is working... I am getting the results page I want, but the data is not being written to "Review".

dave

Quote Reply
Re: Writing HASH to a Table In reply to
Try using:

Code:

$review_db->add ($IN);


Also, I would recommend not using Username as the record owner field...I would recommend using UserID from the Users table...using a volatile/evolving field like Username will only pose problems in the future if you allow your users to edit their username...





Regards,

Eliot Lee
Quote Reply
Re: Writing HASH to a Table In reply to
Did you check the HELP docs? Under Table, there is a whole list of the commands, and how to use them.



PUGDOGŪ Enterprises, Inc.
FAQ:http://LinkSQL.com/FAQ
Forum:http://LinkSQL.com/forum
Quote Reply
Re: Writing HASH to a Table In reply to
Eliot/Pugdog:

Thanks so much for getting me going- I appreciate it. I am trying to get a bare-bones review thing going... (that was obvious, wasn't it?) Anyway, I will forward my work to you Pugdog for your project- I am sure you will improve it a LOT!

Eliot- good point, I will get that changed right away!

Thanks!

Dave

Quote Reply
Re: Writing HASH to a Table In reply to
Hi,

Make sure to do $review_db->add ( { ... } ) or die "Can't add: $GT::SQL::error";

As add won't fatal if there is a problem, you need to catch the error.

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: Writing HASH to a Table In reply to
Alex:

Thanks for the advice. I am learning a LOT doing this! It is kinda slow going, but I am getting there!

Dave