Description:
INSERT INTO `polls` (`question`) VALUES('test');
SELECT LAST_INSERT_ID() FROM `polls`;
# Returns one row with one column with the value of '0'
show create table `polls`;
# Returns the following:
CREATE TABLE `polls` (
`ID` int(11) NOT NULL auto_increment,
`question` varchar(255) NOT NULL default '',
`result` enum('aye','nay') NOT NULL default 'nay',
`status` enum('open','closed') NOT NULL default 'open',
`asker` varchar(50) NOT NULL default '',
PRIMARY KEY (`ID`)
) TYPE=MyISAM
select max(ID) from polls;
# Returns one row with one column with the value of '1'
select * from polls where question='test';
# Returns the following:
ID --- question --- result --- status --- asker
1 --- test --- nay --- open --- NULL
select last_insert_id();
# Returns one row with one column with the value of '0'
Works on command line and everywhere else.
How to repeat:
Follow steps above.
Suggested fix:
Maybe the connection isn't the same somehow? That's the only thing I would think that would cause such a problem as LAST_INSERT_ID is connection-specific.
Description: INSERT INTO `polls` (`question`) VALUES('test'); SELECT LAST_INSERT_ID() FROM `polls`; # Returns one row with one column with the value of '0' show create table `polls`; # Returns the following: CREATE TABLE `polls` ( `ID` int(11) NOT NULL auto_increment, `question` varchar(255) NOT NULL default '', `result` enum('aye','nay') NOT NULL default 'nay', `status` enum('open','closed') NOT NULL default 'open', `asker` varchar(50) NOT NULL default '', PRIMARY KEY (`ID`) ) TYPE=MyISAM select max(ID) from polls; # Returns one row with one column with the value of '1' select * from polls where question='test'; # Returns the following: ID --- question --- result --- status --- asker 1 --- test --- nay --- open --- NULL select last_insert_id(); # Returns one row with one column with the value of '0' Works on command line and everywhere else. How to repeat: Follow steps above. Suggested fix: Maybe the connection isn't the same somehow? That's the only thing I would think that would cause such a problem as LAST_INSERT_ID is connection-specific.