Page 1 of 1

[SOLVED] Question

Posted: Sat May 12, 2007 1:08 pm
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

Posted: Sat May 12, 2007 2:05 pm
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!!:)

[SOLVED] Question

Posted: Sat May 12, 2007 2:22 pm
by Think Pink
thak you