Sorrry, this is another newbie question.

I am using HTML::Widget and DBIx::Class to do simple CRUD on some MySQL
tables. I have defined an auto-increment primary key on one of my tables,
and I want to use an HTML form to populate and create a new object. I then
want to retrieve the newly-generated key.

Sup[pose the SQL has:

CREATE TABLE mytable (
       mytable_id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
       title VARCHAR(64) NOT NULL,
       date VARCHAR(10) NOT NULL,
       PRIMARY KEY (mytable_id);

Having read the examples, I thought that all I had to do is:

            my $obj = $c->model(q{MyAppDB::MyTable})->new({});
            $obj->populate_from_widget($result);
            my $newid = $obj->mytable_id;

but I am finding that the generated SQL is in fact setting the key field to
zero, and then the last line of the above code is getting an undefined value
back.

But then I have not actually told my DBIx::Class package for the table that
the column is autoincrement -- do I need to do this and if so how?

-- 
Regards,
Martin
([EMAIL PROTECTED])
IT: http://methodsupport.com Personal: http://thereisnoend.org
_______________________________________________
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to