Easier yet, when using DBI::mysql, is:

my $IncrementedID = $dbh->{'mysql_insertid'};


When executed after the INSERT command.


Nicholas

-----Original Message-----
From: Rick Emery [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 16, 2002 9:28 AM
To: 'Ben Curran'; [EMAIL PROTECTED]
Subject: RE: auto_increment


To answer your second question about how to retrieve the auto_incremented
values:

$dbh->do("SELECT last_insert_id() AS myvalue");

execute the above IMMEDIATELY after inserting the record



-----Original Message-----
From: Ben Curran [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, January 15, 2002 5:59 PM
To: [EMAIL PROTECTED]
Subject: auto_increment


Sorry if this is a newbie question, I've been through the manual, still
can't figure it out.

If one has created a table, with a key using auto_increment, how does one
Insert data into it? 

If my table consists of (inID (primary key, auto incremented), employeeID
(foreign key) time, date).
if I use 
$dbh->do("INSERT INTO timein VALUES('$employeeID','$timein','$day')");
obviously, it tells me that
DBD::mysql::db do failed: Column count doesn't match value count.

How do I refer to the auto incremented field when attempting to place values
in a new row?

my only thought is that it has something to do with mysql_insert_id. not
sure how though.

thanks.
ben.


This e-mail (and any attachments) is confidential and may contain personal
views which are not the views of the BBC unless specifically stated.
If you have received it in error, please delete it from your system, do not
use,
copy or disclose the information in any way nor act in reliance on it and
notify
the sender immediately. Please note that the BBC monitors e-mails sent
or received. Further communication will signify your consent to this.


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to