Alvaro Cobo wrote:
Hi guys:

I need to execute two insert/update queries within a single statement string
from a PHP
application, but it keeps giving me an error.

For example, I have a listbox which has to insert or update two tables
whithin the same submit action:

INSERT INTO tbl_ISperson(NamePerson, Country) VALUES('John Smith',
'{var_country}');
INSERT INTO tbl_pais_src(name_country) VALUES('{var_country}');
/*Where {var_country}is a variable which stores the value of a country*/

I have found this page
(http://dev.mysql.com/doc/mysql/en/c-api-multiple-queries.html), but I donĀ“t
know how to implement it:

"From version 4.1, MySQL supports the execution of multiple statements
specified in a single query string. To use this capability with a given
connection, you must specify the CLIENT_MULTI_STATEMENTS option in the flags
parameter of mysql_real_connect() when opening the connection. You can also
set this for an existing connection by calling MySQL Reference Manual ::
23.2.9 C API Handling of Multiple Query Execution mysql_set_server_option
MYSQL_OPTION_MULTI_STATEMENTS_ON) By default, mysql_query() and
mysql_real_query() return only the first query status and the subsequent
queries status can be processed using mysql_more_results() and
mysql_next_result()"

Does anybody has tried it in php?. Does anyone could share an example?

Thanks in advance and best regards.

Alvaro.


Is this what your looking for?

http://www.php.net/manual/en/function.mysqli-multi-query.php

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to