I use MySQL and a prepared statement to insert a record BLOB(jpeg image). After executing the prepared statement, I issue SELECT LAST_INSERT_ID()and it returns 0.
In my code, I set a breakpoint after the run command and in the MySQL command window (monitor), I issue SELECT LAST_INSERT_ID()and return 0.
In the MySQL command window (monitor), I issue an SQL statement to select all identifiers, and the last (only) inserted identifier is 1 (one).
I use:
- Server Version: 5.1.46-Community MySQL Community Server (GPL)
- Visual Studio 2008, version 9.
- MySQL Connector C ++ 1.0.5
Description of my table:
mysql> describe picture_image_data;
+---------------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------------+------------------+------+-----+---------+----------------+
| ID_Image_Data | int(10) unsigned | NO | PRI | NULL | auto_increment |
| Image_Data | mediumblob | YES | | NULL | |
+---------------+------------------+------+-----+---------+----------------+
2 rows in set (0.19 sec)
Results using the MySQL monitor:
mysql> select ID_Image_Data
-> from picture_image_data;
+---------------+
| ID_Image_Data |
+---------------+
| 1 |
+---------------+
1 row in set (0.00 sec)
mysql> SELECT LAST_INSERT_ID();
+------------------+
| LAST_INSERT_ID() |
+------------------+
| 0 |
+------------------+
1 row in set (0.00 sec)
Prepared statement:
INSERT INTO Picture_Image_Data
(ID_Image_Data, Image_Data)
VALUES
(?,
?);
, ID_Image_Data , LAST_INSERT_ID . , .
:
ID , - ++ std::istream *. MySQL LAST_INSERT_ID():
LAST_INSERT_ID() , AUTO_INCREMENT "" ( , NULL, 0).
LAST_INSERT_ID() 1, 0.
LAST_INSERT_ID?
{ , API MySQL, PHP , ).