how i can get inserted id by php and oracle
i know that its not first time someone ask this question, i look at questions in stakoverflow which covered same subject but they didnt give me what i need, my request is how can get inserted id by php and oracle i have table named USERS with 3 columns ID, USERNAME, PASSWORD so i neeed the inserted primary id
i know how make that by php + mysql
$insert = mysql_query("INSERT INTO USERS(USERNAME,PASSWORD)VALUES('{JOHN}','{1235}')"开发者_开发技巧);
if(!$insert){
die(mysql_error());
}
echo mysql_inserted_id();
please help me to do it in oracle i want do it with out use OCIBindByName
OCILogon is a synonym for oci_connect. Please read manual first before saying "I don't use this" ;)
http://php.net/manual/en/function.ocilogon.php
So the solution is here: Get the auto-generated ID after an insert
And I don't see why not to use OCIBindByName. There is nothing to love ;) Just use what's effective and easy.
Do you have think to use a Trigger "Before insert" on Oracle TABLE USERS and an Oracle Sequence to generate a unique number? Oracle Trigger Guide and Use of Oracle Sequences
I think this a possible solution.
Bye
精彩评论