Re: [Catalyst] How to insert from form to MySQL with autoincrement primary key?

2007-12-09 Thread Paul Henrich
Never mind re. PK::Auto. If you have the newest DBIx::Class, that gets automatically loaded. However, you may still need to do __PACKAGE__->set_primary_key(); On 9 Dec 2007, at 3:19 PM, Paul Henrich wrote: Hi Martin, You might check to make sure that you are loading PK::Auto in MyAppDB::

Re: [Catalyst] How to insert from form to MySQL with autoincrement primary key?

2007-12-09 Thread Paul Henrich
Hi Martin, You might check to make sure that you are loading PK::Auto in MyAppDB::MyTable: # ... use base 'DBIx::Class'; __PACKAGE__->load_components("PK::Auto", "Core"); __PACKAGE__->table("mytable"); # then make sure you declare the primary key later on... __PACKAGE__->set_primary_key("my

Re: [Catalyst] How to insert from form to MySQL with autoincrement primary key?

2007-12-09 Thread Ash Berlin
On 9 Dec 2007, at 18:03, Martin Ellison wrote: Yes, I had the DBIC trace going. Basically it did an INSERT (without the key field, correctly), but not a (select of the) LAST_INSERT_ID(), at least, not in the trace. So perhaps it had no way of knowing the new key. It wont do that - it wil

Re: [Catalyst] How to insert from form to MySQL with autoincrement primary key?

2007-12-09 Thread Martin Ellison
Yes, I had the DBIC trace going. Basically it did an INSERT (without the key field, correctly), but not a (select of the) LAST_INSERT_ID(), at least, not in the trace. So perhaps it had no way of knowing the new key. On 10/12/2007, Carl Franks <[EMAIL PROTECTED]> wrote: > > On 09/12/2007, Martin E

Re: [Catalyst] How to insert from form to MySQL with autoincrement primary key?

2007-12-09 Thread Carl Franks
On 09/12/2007, Martin Ellison <[EMAIL PROTECTED]> wrote: > Yes, I had a form field with the same name as the table key, because, when I > do an update on an existing object, I want to save its key value somewhere. > ...I've put in a test, so it only includes the field when I want to d an > update.

Re: [Catalyst] How to insert from form to MySQL with autoincrement primary key?

2007-12-09 Thread Martin Ellison
I tried my $newid = $c->model( q{MyAppDB::MyTable} )->result_source->storage->last_insert_id(); and it gave me zero, so I'm not sure how to proceed. On 10/12/2007, Martin Ellison <[EMAIL PROTECTED]> wrote: > > Yes, I had a form field with the same name as the table key, because, when > I do an u

Re: [Catalyst] How to insert from form to MySQL with autoincrement primary key?

2007-12-09 Thread Martin Ellison
Yes, I had a form field with the same name as the table key, because, when I do an update on an existing object, I want to save its key value somewhere. ...I've put in a test, so it only includes the field when I want to d an update. So now it is formulating the INSERT without the key field, which

Re: [Catalyst] How to insert from form to MySQL with autoincrement primary key?

2007-12-09 Thread Carl Franks
On 09/12/2007, Martin Ellison <[EMAIL PROTECTED]> wrote: > 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 an

[Catalyst] How to insert from form to MySQL with autoincrement primary key?

2007-12-09 Thread Martin Ellison
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