Modules/MySQL/MysqlQuery: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
==Description== | ==Description== | ||
This functions queries the MySQL server through the MySQL connection that has been opened by [[mysqlOpen]]. The result of the query is then passed to the script by calling callback_function. | This functions queries the MySQL server through the MySQL connection that has been opened by [[mysqlOpen]]. The result of the query is then passed to the script by calling callback_function. It's syntax and functionality is similar to that of [[executeSQLSelect]]. | ||
This function is provided by the | This function is provided by the [[Module functions|ml_mysql]] module. | ||
==Syntax== | ==Syntax== |
Revision as of 01:20, 1 November 2006
Description
This functions queries the MySQL server through the MySQL connection that has been opened by mysqlOpen. The result of the query is then passed to the script by calling callback_function. It's syntax and functionality is similar to that of executeSQLSelect.
This function is provided by the ml_mysql module.
Syntax
bool mysqlQuery ( mysql object, string callback_function, string query )
Required Arguments
- mysql : The mysql object returned by mysqlOpen
- callback_function : The function that is called if the operation is done (please see below)
- query : The MySQL query that is sent
Callback Arguments
Your callback function has to accept the following arguments.
On success:
- table: The 2-dimensional table where the results are stored in: table [row_index] [column_index].
On failure:
- boolean: False, when no rows are found or an error occured.
Optional Arguments
None
Example
function onMySQLResult ( table ) outputServerLog ( "GOT RESULT" ) outputServerLog ( table[1][1] ) outputServerLog ( table[1][2] ) end function onMySQLOpen ( mysql, result ) if ( result ) then outputServerLog ( "CONNECTED" ) mysqlQuery ( mysql, "onMySQLResult", "SELECT * FROM test" ) else outputServerLog ( "DIDNT WORK" ) end end function mysqltest () mysqlOpen ( "onMySQLOpen", "localhost", "bastage", "bastage_pw", "test", 3306 ) end