mysql_insert_id - link_identifier

From: Date: Mon, 28 Jan 2002 12:18:50 +0000
Subject: mysql_insert_id - link_identifier
Groups: php.db 
Request: Send a blank email to php-db+get-16238@lists.php.net to get a copy of this message
I already run the query without the value of the primary-key field: >> $q_orders_id2 = "INSERT INTO orders(orders_datum, orders_sessid)"; $q_orders_id2.= " VALUES ('$date', '$sid')"; $r_orders_id2 = mysql_query($q_orders_id2, $sqllink_id); $orders_id = mysql_insert_id($sqllink_id); << The primary-key field is: "orders_id" (not in above query). Only "orders_datum" and "orders_sessid" are sent with the query. When I call mysql_insert_id with tha vars: "$q_orders_id" or "$r_orders_id" I get an warning (Warning: Supplied argument is not a valid MySQL-Link resource in /home/httpd/blabla/file.php on line 91) but not the wanted id. In the manual it says that mysql_insert_id() is used with the linkidentifier ($sqllink_id ? ) but not how to define the identifier in mysql_query()... >>How do I define a linkidentifier for a specific call to mysql_query() and then use mysql_insert_id() with that linkidentifier of the query? regards Bart -----Oorspronkelijk bericht----- Van: Alberto. Sartori [mailto:alberto.sartori@cellnetwork.it] Verzonden: maandag 28 januari 2002 13:11 Aan: b.verbeek@creative-edge.nl Onderwerp: R: [PHP-DB] mysql_insert_id - link_identifier Run the query without the value of the primary-key field. -----Messaggio originale----- Da: B. Verbeek [mailto:b.verbeek@creative-edge.nl] Inviato: lunedì 28 gennaio 2002 13.08 A: Alberto. Sartori Oggetto: RE: [PHP-DB] mysql_insert_id - link_identifier ? How do you mean ? regards -----Oorspronkelijk bericht----- Van: Alberto. Sartori [mailto:alberto.sartori@cellnetwork.it] Verzonden: maandag 28 januari 2002 12:35 Aan: b.verbeek@creative-edge.nl Onderwerp: R: [PHP-DB] mysql_insert_id - link_identifier You can omit the primary key if the filed have auto-increment type -----Messaggio originale----- Da: B. Verbeek [mailto:b.verbeek@creative-edge.nl] Inviato: lunedì 28 gennaio 2002 12.29 A: Php-Db-Help (E-mail) Oggetto: [PHP-DB] mysql_insert_id - link_identifier Hello, How do I use the linkidentifier to get me the last_inserted_id (mysql_insert_id) from a auto_increment-colomn? Do I use: >> $q_orders_id2 = "INSERT INTO orders(orders_datum, orders_sessid)"; $q_orders_id2.= " VALUES ('$date', '$sid')"; $r_orders_id2 = mysql_query($q_orders_id2, $sqllink_id); $orders_id = mysql_insert_id($sqllink_id); << "$sqllink_id" must be the inserted value for the auto-increment-colomn named "orders_id" and is placed in var "$orders_id" Can anyone tell me if this is correct and what can be done to optimize? regards Bart -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net For additional commands, e-mail: php-db-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.db (#16238) next »