Welcome Guest, Not a member yet? Register   Sign In
Need php equivalant for the JAVA snippet
#1

[eluser]halwaraj[/eluser]
I have this JAVA code snippet:

Code:
PreparedStatement ps = conn.prepareStatement("insert query for auto key table", Statement.RETURN_GENERATED_KEYS);

Is there something similar in CI. Its there in ZEND i know.

The above code snippet returns the auto generated keys like PK, to be used later as FK.
#2

[eluser]xwero[/eluser]
db->insert_id is the first thing i think of
#3

[eluser]halwaraj[/eluser]
Any ideas how does the above function call work?

I mean the implementation.

There might be situation wherein I insert a row (suppose the generated id is 6) and before I call the db->insert_id, somebody else inserts other records into the database (and suppose the generated id in this case is 7). So what am I gonna get when I call the above function? Is it 6 or 7?

I mean there would be a lot of simultaneous requests in the real world.
#4

[eluser]xwero[/eluser]
In the mysql driver it uses mysql_insert_id which uses mysql's last_insert_id function internally i guess.
How is it done in java?




Theme © iAndrew 2016 - Forum software by © MyBB