Advertisement
Guest User

MySQL 2.1.1

a guest
Mar 13th, 2012
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 6.77 KB | None | 0 0
  1. /**
  2.  *     SA:MP MySQL v2.1 Functions
  3.  *  (c) Copyright 2011, StrickenKid
  4.  *
  5.  **/
  6.  
  7. #if defined __mysql_included
  8.     #endinput
  9. #endif
  10.  
  11. #define __mysql_included
  12. #pragma library mysql
  13.  
  14. // plugin error id's
  15.  
  16. #define P_ERROR_NONE                                0
  17. #define P_ERROR_INCPARAMCNT                         1
  18. #define P_ERROR_INCVALUE                            2
  19. #define P_ERROR_MAXCONN                             3
  20. #define P_ERROR_DBNOCONN                            4
  21. #define P_ERROR_NORES                               5
  22. #define P_ERROR_RES                                 6
  23. #define P_ERROR_NOFIELD                             7
  24. #define P_ERROR_NOFIELDDATA                         8
  25. #define P_ERROR_NOROWDATA                           9
  26. #define P_ERROR_CANTALLOC                           10
  27. #define P_ERROR_NOCALLBACK                          11
  28. #define P_ERROR_NOQUERY                             12
  29.  
  30. // mysql headers defines
  31.  
  32. #define REFRESH_GRANT                               1
  33. #define REFRESH_LOG                                 2
  34. #define REFRESH_TABLES                              4
  35. #define REFRESH_HOSTS                               8
  36. #define REFRESH_STATUS                              16
  37. #define REFRESH_THREADS                             32
  38. #define REFRESH_SLAVE                               64
  39. #define REFRESH_MASTER                              128
  40.  
  41. // mysql error id's
  42.  
  43. #define CR_ERROR_FIRST                              2000
  44. #define CR_UNKNOWN_ERROR                            2000
  45. #define CR_SOCKET_CREATE_ERROR                      2001
  46. #define CR_CONNECTION_ERROR                         2002
  47. #define CR_CONN_HOST_ERROR                          2003
  48. #define CR_IPSOCK_ERROR                             2004
  49. #define CR_UNKNOWN_HOST                             2005
  50. #define CR_SERVER_GONE_ERROR                        2006
  51. #define CR_VERSION_ERROR                            2007
  52. #define CR_OUT_OF_MEMORY                            2008
  53. #define CR_WRONG_HOST_INFO                          2009
  54. #define CR_LOCALHOST_CONNECTION                     2010
  55. #define CR_TCP_CONNECTION                           2011
  56. #define CR_SERVER_HANDSHAKE_ERR                     2012
  57. #define CR_SERVER_LOST                              2013
  58. #define CR_COMMANDS_OUT_OF_SYNC                     2014
  59. #define CR_NAMEDPIPE_CONNECTION                     2015
  60. #define CR_NAMEDPIPEWAIT_ERROR                      2016
  61. #define CR_NAMEDPIPEOPEN_ERROR                      2017
  62. #define CR_NAMEDPIPESETSTATE_ERROR                  2018
  63. #define CR_CANT_READ_CHARSET                        2019
  64. #define CR_NET_PACKET_TOO_LARGE                     2020
  65. #define CR_EMBEDDED_CONNECTION                      2021
  66. #define CR_PROBE_SLAVE_STATUS                       2022
  67. #define CR_PROBE_SLAVE_HOSTS                        2023
  68. #define CR_PROBE_SLAVE_CONNECT                      2024
  69. #define CR_PROBE_MASTER_CONNECT                     2025
  70. #define CR_SSL_CONNECTION_ERROR                     2026
  71. #define CR_MALFORMED_PACKET                         2027
  72. #define CR_WRONG_LICENSE                            2028
  73. #define CR_NULL_POINTER                             2029
  74. #define CR_NO_PREPARE_STMT                          2030
  75. #define CR_PARAMS_NOT_BOUND                         2031
  76. #define CR_DATA_TRUNCATED                           2032
  77. #define CR_NO_PARAMETERS_EXISTS                     2033
  78. #define CR_INVALID_PARAMETER_NO                     2034
  79. #define CR_INVALID_BUFFER_USE                       2035
  80. #define CR_UNSUPPORTED_PARAM_TYPE                   2036
  81. #define CR_SHARED_MEMORY_CONNECTION                 2037
  82. #define CR_SHARED_MEMORY_CONNECT_REQUEST_ERROR      2038
  83. #define CR_SHARED_MEMORY_CONNECT_ANSWER_ERROR       2039
  84. #define CR_SHARED_MEMORY_CONNECT_FILE_MAP_ERROR     2040
  85. #define CR_SHARED_MEMORY_CONNECT_MAP_ERROR          2041
  86. #define CR_SHARED_MEMORY_FILE_MAP_ERROR             2042
  87. #define CR_SHARED_MEMORY_MAP_ERROR                  2043
  88. #define CR_SHARED_MEMORY_EVENT_ERROR                2044
  89. #define CR_SHARED_MEMORY_CONNECT_ABANDONED_ERROR    2045
  90. #define CR_SHARED_MEMORY_CONNECT_SET_ERROR          2046
  91. #define CR_CONN_UNKNOW_PROTOCOL                     2047
  92. #define CR_INVALID_CONN_HANDLE                      2048
  93. #define CR_SECURE_AUTH                              2049
  94. #define CR_FETCH_CANCELED                           2050
  95. #define CR_NO_DATA                                  2051
  96. #define CR_NO_STMT_METADATA                         2052
  97. #define CR_NO_RESULT_SET                            2053
  98. #define CR_NOT_IMPLEMENTED                          2054
  99. #define CR_SERVER_LOST_EXTENDED                     2055
  100. #define CR_STMT_CLOSED                              2056
  101. #define CR_NEW_STMT_METADATA                        2057
  102. #define CR_ERROR_LAST                               2057
  103.  
  104. // logging types
  105.  
  106. #define INVALID_MYSQL_ID                            (-1)
  107. #define LOG_OFF                                     (0)
  108. #define LOG_ALL                                     (1)
  109. #define LOG_ONLY_ERRORS                             (2)
  110.  
  111. // function defines
  112.  
  113. #define mysql_reload(%1) mysql_refresh(REFRESH_GRANT, %1)
  114.  
  115. // plugin callbacks
  116.  
  117. forward OnMysqlQueryArray(resultid, extravars[], MySQL:handle);
  118. forward OnMysqlQuery(resultid, spareid, MySQL:handle);
  119. forward OnMysqlError(error[], errorid, MySQL:handle);
  120.  
  121. // plugin natives
  122.  
  123. native MySQL:mysql_init(logtype = LOG_ONLY_ERRORS, printerrors = 1);
  124. native mysql_connect(const host[], const user[], const pass[], const db[], MySQL:handle = (MySQL:0), auto_reconnect = 0);
  125. native mysql_close(MySQL:handle = (MySQL:0));
  126. native mysql_refresh(options, MySQL:handle = (MySQL:0));
  127. native mysql_select_db(const db[], MySQL:handle = (MySQL:0));
  128. native mysql_query(const query[], resultid = (-1), spareid = (0), MySQL:handle = (MySQL:0));
  129. native mysql_query_array(const query[], resultid = (-1), {Float,_}:extravars[], MySQL:handle = (MySQL:0));
  130. native mysql_store_result(MySQL:handle = (MySQL:0));
  131. native mysql_free_result(MySQL:handle = (MySQL:0));
  132. native mysql_result_stored(MySQL:handle = (MySQL:0));
  133. native mysql_fetch_field(const fieldname[], dest[], MySQL:handle = (MySQL:0));
  134. native mysql_fetch_field_num(fieldnum, dest[], MySQL:handle = (MySQL:0));
  135. native mysql_fetch_row(dest[], const splitter[] = "|", MySQL:handle = (MySQL:0));
  136. native mysql_fetch_row_data(MySQL:handle = (MySQL:0));
  137. native mysql_real_escape_string(const string[], dest[], MySQL:handle = (MySQL:0));
  138. native mysql_num_rows(MySQL:handle = (MySQL:0));
  139. native mysql_num_fields(MySQL:handle = (MySQL:0));
  140. native mysql_affected_rows(MySQL:handle = (MySQL:0));
  141. native mysql_insert_id(MySQL:handle = (MySQL:0));
  142. native mysql_ping(MySQL:handle = (MySQL:0));
  143. native mysql_error(dest[], MySQL:handle = (MySQL:0));
  144. native mysql_errno(MySQL:handle = (MySQL:0));
  145. native mysql_warning_count(MySQL:handle = (MySQL:0));
  146. native mysql_info(dest[], MySQL:handle = (MySQL:0));
  147. native mysql_stat(dest[], MySQL:handle = (MySQL:0));
  148. native mysql_get_server_info(dest[], MySQL:handle = (MySQL:0));
  149. native mysql_get_host_info(dest[], MySQL:handle = (MySQL:0));
  150. native mysql_data_seek(rownum, MySQL:handle = (MySQL:0));
  151. native mysql_set_character_set(const csname[], MySQL:handle = (MySQL:0));
  152. native mysql_get_character_set(csname[], MySQL:handle = (MySQL:0));
  153. native mysql_fetch_int(MySQL:handle = (MySQL:0));
  154. native Float:mysql_fetch_float(MySQL:handle = (MySQL:0));
  155. native mysql_fetch_string(dest[], MySQL:handle = (MySQL:0));
  156.  
  157. #if !defined split
  158. // split function - thanks to Blacklite
  159. stock split(const strsrc[], strdest[][], delimiter = '|')
  160. {
  161.     new i, li, aNum, len, srclen = strlen(strsrc);
  162.     while(i <= srclen)
  163.     {
  164.         if (strsrc[i] == delimiter || i == srclen)
  165.         {
  166.             len = strmid(strdest[aNum], strsrc, li, i, 128);
  167.             strdest[aNum][len] = 0;
  168.             li = i + 1;
  169.             aNum++;
  170.         }
  171.         i++;
  172.     }
  173. }
  174. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement