List:General Discussion« Previous MessageNext Message »
From:Thimble Smith Date:October 8 1999 6:25pm
Subject:Re: finding AUTO_INCREMENT type from client side
View as plain text  
At 12:49, 19991008, Jim O'Quinn wrote:
> T_SOME_TABLE.ID		- auto_increment
> T_SOME_TALBE.SOME_CHAR		- char
>
> my $obj	= new T_SOME_TABLE();
> $obj->setSomeChar(12);
> $obj->store;  # does update/insert
>
>Then I can do:
>
> print $obj->getSomeChar;	# a '12' shows up
> print $obj->getId;		# here is where I need to get 
>                                # the value that was auto_incremented

Jim, don't you need to know before you do the update/insert, whether
it's auto_increment or not?  Otherwise you don't know if you need to
supply a value (which value, by the way?) or NULL (auto_increment).
You're already assuming something about the ID column, it seems to me
(although, obviously, I've only got a scrap of an idea about what you
are doing).

I'm not trying to avoid the real question.  I should, because I don't
know how to get this out of Mysql.pm (short of hacking Mysql.pm, which
is a dead duck anyway, so I don't know how useful that would be).  But
I am trying to figure out if there isn't a better way to organize your
program, so that you don't need to find out if the id is auto_increment
or not.  Perhaps you could structure it so that every table that is used
in this way MUST have an auto_increment id.  Then you know the answer
even before you start.  Or perhaps you could store a logical (to your
class, that is) table definition when you create the tables, which lets
you know all sorts of good stuff about the tables in question, including
whether or not they have auto_increment IDs.

Sorry for the rambling prose - I'm rather scattered at the moment.

Tim
Thread
finding AUTO_INCREMENT type from client sideJim O'Quinn7 Oct
  • Re: finding AUTO_INCREMENT type from client sideThimble Smith7 Oct
  • Re: finding AUTO_INCREMENT type from client sideJim O'Quinn7 Oct
    • Re: finding AUTO_INCREMENT type from client sideMichael Widenius8 Oct
  • Re: finding AUTO_INCREMENT type from client sideJim O'Quinn8 Oct
    • Re: finding AUTO_INCREMENT type from client sideThimble Smith8 Oct
  • Re: finding AUTO_INCREMENT type from client sideJim O'Quinn8 Oct
    • Re: finding AUTO_INCREMENT type from client sideThimble Smith8 Oct
    • Re: finding AUTO_INCREMENT type from client sideMichael Widenius10 Oct