![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
and subscription also has a "id" field which is auto_increment, doesn't work. The id field gets some seemingly random value. How can I make sure auto_increment works? |
#3
| |||
| |||
|
|
On Mon, Mar 14, 2005 at 08:35:27PM +0100, Joachim Person wrote: and subscription also has a "id" field which is auto_increment, doesn't work. The id field gets some seemingly random value. How can I make sure auto_increment works? auto_increment happens at the database level. I don't believe mysql++ automatically updates the struct with the new id, you need to get it yourself with the insert_id() call. query.store(); int id = connection.insert_id();// do this right after the // insert operation |
#4
| |||
| |||
|
|
query.insert(subscription); |
#5
| |||
| |||
|
|
I *think* -- and this is where it gets quite hazy for me, because I have not actually used either the specialized structures OR the Null class (though I do need to use the Null class at some point) you will need to do something like this: subscription.id = Null<int>; However, I'm not 100% sure that works with the specialized type classes without going into the code and seeing if they respect the Null class. I should imagine they do, but imagining will not make it so =) |
#6
| |||
| |||
|
|
when you leave the auto_increment column out of the insert, MySQL picks the value for that column for you. |
![]() |
| Thread Tools | |
| Display Modes | |
| |