[Comment] Can't return a result set in the given context and parameter explanation

Source: Internet
Author: User
Tags signal handler mysql command line

I wrote a MySQL stored procedure and thought that PHP has built-in functions used to call the stored procedure. I found that I can only use mysql_query (call pro, in my opinion, it is essentially equivalent to executing a statement in the MySQL command line. Because my Stored Procedure contains input and output parameters, a mysql_error Error error will be reported during direct calling: xxxxcan't return a result set in the given context
 

Google found this error and someone used the following Code Solved this problem:
Address: http://www.phpweblog.net/GaRY/archive/2008/01/29/2752.html#Post

Two key points

Define ( 'Client _ multi_results' , 131072 ) ;

$ Link = Mysql_connect ( "127.0.0.1" , "Root" , "" , 1 , Client_multi_results ) Or die ( "Cocould not connect :" . Mysql_error ( ) ) ;

The following is an example.Program.

1 < ? PHP
2 Define ( 'Client _ multi_results' , 131072 ) ;
3
4 $ Link = Mysql_connect ( "127.0.0.1" , "Root" , "" , 1 , Client_multi_results ) Or Die ( "Cocould not connect :" . Mysql_error ( ) ) ;
5 Mysql_select_db ( "" ) Or Die ( "Cocould not select database" ) ;
6 ? >
7
8 < ? PHP
9 $ Result = Mysql_query ( "Call get_news_from_class_id (2 )" ) Or Die ( "Query failed :" . Mysql_error ( ) ) ;
10 While ( $ Row = Mysql_fetch_array ( $ Result , Mysql_assoc ) )
11 {
12 $ Line = '<Tr> <TD> <a target = _ blank href = \'' . $ Row [ "Url" ] . '\'>' . $ Row [ "Title" ] . '(' . $ Row [ "Page_time" ] . ')' . '</A> </TD> </tr>' ;
14 Echo $ Line ;
15 Printf ( "" ) ;
16
17 }
18 Mysql_free_result ( $ Result ) ;
19 ? >
20
21 < ? PHP
22 Mysql_close ( $ Link ) ;
23 ? >

One of the parameters client_multi_results doesn't understand what it means, Google, documentation on the MySQL official homepage about the C interface provided by MySQL (http://dev.mysql.com/doc/refman/5.0/en/mysql-real-connect.html) this parameter and other parameters are found. I have translated the description as follows:

Flag name Flag description
Client_compress Use compression Protocol .(Use the compression Protocol.)
Client_found_rows Return the number of found (matched) rows, not the number of changed rows .(Returns the number of rows found (matched), instead of the number of rows changed..)
Client_ignore_sigpipe Prevents the client library from installing a sigpipe signal handler. This can be used to avoid conflicts with a handler that the application has already installed .(Prevents the client library from installing a sigpipe signal processor. This can be used to avoid conflicts when the application has installed the processor.)
Client_ignore_space Allow spaces after function names. Makes all functions names reserved words .(Space is allowed after the function name. Reserved Words for all function names.)
Client_interactive AllowInteractive_timeoutSeconds (insteadWait_timeoutSeconds) of inactivity before closing the connection. The client's sessionWait_timeoutVariable is set to the value of the sessionInteractive_timeoutVariable .(Allow the description of the inactive interaction timeout before closing the connection, instead of waiting for the timeout seconds. The client's session wait timeout variable changes to the interaction timeout variable..)
Client_local_files EnableLoad data localHandling.
Client_multi_results Tell the server that the client can handle multiple result sets from multiple-statement executions or stored procedures. this flag is automatically enabled if client_multi_statements is enabled. see the note following this table for more information about this flag. (The Notification Server Client can process multiple result sets generated by multiple statements or stored procedure execution. When enabledWhen client_multi_statements,This flag is automatically opened. You can view more information about the flag after the table.)
Client_multi_statements Tell the server that the client may send multiple statements in a single string (separated by ";"). if this flag is not set, multiple-statement execution is disabled. see the note following this table for more information about this flag. (The Notification Server Client can send multiple statements (separated by semicolons ). If this flag is not set, multiple statements are executed..)
Client_no_schema Don't allowDb_name.tbl_name.col_nameSyntax. This is for ODBC. It causes the parser to generate an error if you use that syntax, which is useful for trapping bugs in some ODBC programs .(The syntax "database name. Table name. Column name" is not allowed. This is the configuration for ODBC. When such a syntax is used, the parser will generate an error, which is useful for some ODBC program restriction bugs.)
Client_odbc Unused. (Not used)
Client_ssl Use SSL (encrypted protocol). This option shocould not be set by application programs; it is set internally in the client library. Instead, useMysql_ssl_set ()Before callingMysql_real_connect ().(Use SSL. This setting should not be set by the application. It should be set inside the client library. You can call mysql_ssl_set () to replace the settings before calling mysql_real_connect.)
client_remember_options remember options specified by callto mysql_options () . without this option, if mysql_real_connect () fails, you must repeat the mysql_options () callbefore trying to connect again. with this option, the mysql_options () callneed not be repeated. (< SPAN style = "font-weight: bold;"> remember the settings generated by calling mysql_options. If this setting is not used, mysql_real_connect must be called repeatedly before the connection is reconnected (). Of course, if you use this setting, you do not have to call it repeatedly. )

The following describes client_multi_statements:
If you enable client_multi_statements or client_multi_results, you shocould process the result for every callMysql_query ()OrMysql_real_query ()By using a loop that cballsMysql_next_result ()To determine whether there are more results. For an example, seeSection 9.12, "c api support for multiple statement execution".

IfClient_multi_statements or client_multi_results. You must use a loop to process the call results of each mysql_query () or mysql_real_query (). In this loop, call mysql_next_result () to determine (discovery) whether there are more results, suchSection 9.12, "c api support for multiple statement execution"

Auto: http://hi.baidu.com/dongshenghongr/blog/item/cadbb2017fed15c3267fb520.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.