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

2007-12-09 Thread Martin Ellison
OK, I have changed my code a bit, so that it now has $obj = $c->model( q{MyAppDB::MyTable})->create( {} ); $obj->populate_from_widget($result); In other words, I have replaced the 'new' in the first line by a 'create'. The result (as verified by the DBIC trace) is an insert wit

Re: [Catalyst] Soundboard: Catalyst::Model::GoogleCalendar

2007-12-09 Thread Ashley Pond V
Right on. I swear I tried a search for it. must have misspelled it. On Dec 9, 2007, at 5:05 PM, Steve Sabljak wrote: Using the existing Google Calendar perl api from CPAN (http://search.cpan.org/~simonw/Net-Google-Calendar-0.8/), would this do the trick? package Catalyst::Model::GoogleCalendar

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

2007-12-09 Thread Martin Ellison
My table class is basically: use base qw/DBIx::Class/; __PACKAGE__->load_components(qw/PK::Auto Core HTMLWidget/); # Set the table name __PACKAGE__->table('mytable'); # Set columns in table __PACKAGE__->add_columns( qw/mytable_id title date/ ); # Set the primary key for the table __PACKAGE

Re: [Catalyst] Soundboard: Catalyst::Model::GoogleCalendar

2007-12-09 Thread Steve Sabljak
Using the existing Google Calendar perl api from CPAN (http://search.cpan.org/~simonw/Net-Google-Calendar-0.8/), would this do the trick? package Catalyst::Model::GoogleCalendar; use strict; use base 'Catalyst::Model'; use Class::C3; use Net::Google::Calendar; our $VERSION = '0.1'; sub new {

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

2007-12-09 Thread kevin montuori
> "PH" == Paul Henrich <[EMAIL PROTECTED]> writes: PH> You might check to make sure that you are loading PK::Auto in PH> MyAppDB::MyTable: I belive that with a recent DBIx::Class that's not necessary: perldoc DBIx::Class::PK::Auto indicates that "PK::Auto is now part of Core." k. -- k

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