[SOLVED] Question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Think Pink
Forum Contributor
Posts: 106
Joined: Mon Aug 02, 2004 3:29 pm

[SOLVED] Question

Post by Think Pink »

hello,
i am not shure if this is a correct place to ask this, if not, pls excuse me, and move it to the propper place.
pls explain what committing means and perhaps give me an example
I have no ideea what this means in english in regard with programming and I found it in the php manual.

Ex
When used in transactions, mysql_insert_id() MUST be called before committing.
Thx
Last edited by Think Pink on Sat May 12, 2007 2:23 pm, edited 1 time in total.
Sparky
Forum Newbie
Posts: 11
Joined: Sat May 12, 2007 10:54 am

Post by Sparky »

Hey,

It means - if you're combining a load of MySQL commands together as a transaction, you call "committ" to say "save those commands" (write the data). So ...

INSERT INTO abc VALUES (1,2,3);
INSERT INTO abc VALUES (3,4,5);
INSERT INTO abc VALUES (11,22,33);
INSERT INTO abc VALUES (111,222,333);
COMMIT;

(That's not actual code - just to give the idea!).

If you wanted to call mysql_insert_id to get the last ID inserted you should put this *before* you commit the transaction... thus ...

INSERT INTO abc VALUES (1,2,3);
INSERT INTO abc VALUES (3,4,5);
INSERT INTO abc VALUES (11,22,33);
INSERT INTO abc VALUES (111,222,333);
...
$id = mysql_insert_id($dbhandler);
...
COMMIT;

otherwise it'll not work as intended...

Hope that helps!!:)
User avatar
Think Pink
Forum Contributor
Posts: 106
Joined: Mon Aug 02, 2004 3:29 pm

[SOLVED] Question

Post by Think Pink »

thak you
Post Reply