PageRenderTime 56ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 1ms

/vendor/thecodingmachine/safe/generated/sqlsrv.php

https://gitlab.com/wendy-du-973/club-invest-gr2
PHP | 429 lines | 146 code | 31 blank | 252 comment | 21 complexity | b534eea7a88269322e7180f450e93606 MD5 | raw file
  1. <?php
  2. namespace Safe;
  3. use Safe\Exceptions\SqlsrvException;
  4. /**
  5. * The transaction begun by sqlsrv_begin_transaction includes
  6. * all statements that were executed after the call to
  7. * sqlsrv_begin_transaction and before calls to
  8. * sqlsrv_rollback or sqlsrv_commit.
  9. * Explicit transactions should be started and committed or rolled back using
  10. * these functions instead of executing SQL statements that begin and commit/roll
  11. * back transactions. For more information, see
  12. * SQLSRV Transactions.
  13. *
  14. * @param resource $conn The connection resource returned by a call to sqlsrv_connect.
  15. * @throws SqlsrvException
  16. *
  17. */
  18. function sqlsrv_begin_transaction($conn): void
  19. {
  20. error_clear_last();
  21. $result = \sqlsrv_begin_transaction($conn);
  22. if ($result === false) {
  23. throw SqlsrvException::createFromPhpError();
  24. }
  25. }
  26. /**
  27. * Cancels a statement. Any results associated with the statement that have not
  28. * been consumed are deleted. After sqlsrv_cancel has been
  29. * called, the specified statement can be re-executed if it was created with
  30. * sqlsrv_prepare. Calling sqlsrv_cancel
  31. * is not necessary if all the results associated with the statement have been
  32. * consumed.
  33. *
  34. * @param resource $stmt The statement resource to be cancelled.
  35. * @throws SqlsrvException
  36. *
  37. */
  38. function sqlsrv_cancel($stmt): void
  39. {
  40. error_clear_last();
  41. $result = \sqlsrv_cancel($stmt);
  42. if ($result === false) {
  43. throw SqlsrvException::createFromPhpError();
  44. }
  45. }
  46. /**
  47. * Returns information about the client and specified connection
  48. *
  49. * @param resource $conn The connection about which information is returned.
  50. * @return array Returns an associative array with keys described in the table below.
  51. *
  52. * Array returned by sqlsrv_client_info
  53. *
  54. *
  55. *
  56. * Key
  57. * Description
  58. *
  59. *
  60. *
  61. *
  62. * DriverDllName
  63. * SQLNCLI10.DLL
  64. *
  65. *
  66. * DriverODBCVer
  67. * ODBC version (xx.yy)
  68. *
  69. *
  70. * DriverVer
  71. * SQL Server Native Client DLL version (10.5.xxx)
  72. *
  73. *
  74. * ExtensionVer
  75. * php_sqlsrv.dll version (2.0.xxx.x)
  76. *
  77. *
  78. *
  79. *
  80. * @throws SqlsrvException
  81. *
  82. */
  83. function sqlsrv_client_info($conn): array
  84. {
  85. error_clear_last();
  86. $result = \sqlsrv_client_info($conn);
  87. if ($result === false) {
  88. throw SqlsrvException::createFromPhpError();
  89. }
  90. return $result;
  91. }
  92. /**
  93. * Closes an open connection and releases resourses associated with the connection.
  94. *
  95. * @param resource $conn The connection to be closed.
  96. * @throws SqlsrvException
  97. *
  98. */
  99. function sqlsrv_close($conn): void
  100. {
  101. error_clear_last();
  102. $result = \sqlsrv_close($conn);
  103. if ($result === false) {
  104. throw SqlsrvException::createFromPhpError();
  105. }
  106. }
  107. /**
  108. * Commits a transaction that was begun with sqlsrv_begin_transaction.
  109. * The connection is returned to auto-commit mode after sqlsrv_commit
  110. * is called. The transaction that is committed includes all statements that were
  111. * executed after the call to sqlsrv_begin_transaction.
  112. * Explicit transactions should be started and committed or rolled back using these
  113. * functions instead of executing SQL statements that begin and commit/roll back
  114. * transactions. For more information, see
  115. * SQLSRV Transactions.
  116. *
  117. * @param resource $conn The connection on which the transaction is to be committed.
  118. * @throws SqlsrvException
  119. *
  120. */
  121. function sqlsrv_commit($conn): void
  122. {
  123. error_clear_last();
  124. $result = \sqlsrv_commit($conn);
  125. if ($result === false) {
  126. throw SqlsrvException::createFromPhpError();
  127. }
  128. }
  129. /**
  130. * Changes the driver error handling and logging configurations.
  131. *
  132. * @param string $setting The name of the setting to set. The possible values are
  133. * "WarningsReturnAsErrors", "LogSubsystems", and "LogSeverity".
  134. * @param mixed $value The value of the specified setting. The following table shows possible values:
  135. *
  136. * Error and Logging Setting Options
  137. *
  138. *
  139. *
  140. * Setting
  141. * Options
  142. *
  143. *
  144. *
  145. *
  146. * WarningsReturnAsErrors
  147. * 1 (TRUE) or 0 (FALSE)
  148. *
  149. *
  150. * LogSubsystems
  151. * SQLSRV_LOG_SYSTEM_ALL (-1)
  152. * SQLSRV_LOG_SYSTEM_CONN (2)
  153. * SQLSRV_LOG_SYSTEM_INIT (1)
  154. * SQLSRV_LOG_SYSTEM_OFF (0)
  155. * SQLSRV_LOG_SYSTEM_STMT (4)
  156. * SQLSRV_LOG_SYSTEM_UTIL (8)
  157. *
  158. *
  159. * LogSeverity
  160. * SQLSRV_LOG_SEVERITY_ALL (-1)
  161. * SQLSRV_LOG_SEVERITY_ERROR (1)
  162. * SQLSRV_LOG_SEVERITY_NOTICE (4)
  163. * SQLSRV_LOG_SEVERITY_WARNING (2)
  164. *
  165. *
  166. *
  167. *
  168. * @throws SqlsrvException
  169. *
  170. */
  171. function sqlsrv_configure(string $setting, $value): void
  172. {
  173. error_clear_last();
  174. $result = \sqlsrv_configure($setting, $value);
  175. if ($result === false) {
  176. throw SqlsrvException::createFromPhpError();
  177. }
  178. }
  179. /**
  180. * Executes a statement prepared with sqlsrv_prepare. This
  181. * function is ideal for executing a prepared statement multiple times with
  182. * different parameter values.
  183. *
  184. * @param resource $stmt A statement resource returned by sqlsrv_prepare.
  185. * @throws SqlsrvException
  186. *
  187. */
  188. function sqlsrv_execute($stmt): void
  189. {
  190. error_clear_last();
  191. $result = \sqlsrv_execute($stmt);
  192. if ($result === false) {
  193. throw SqlsrvException::createFromPhpError();
  194. }
  195. }
  196. /**
  197. * Frees all resources for the specified statement. The statement cannot be used
  198. * after sqlsrv_free_stmt has been called on it. If
  199. * sqlsrv_free_stmt is called on an in-progress statement
  200. * that alters server state, statement execution is terminated and the statement
  201. * is rolled back.
  202. *
  203. * @param resource $stmt The statement for which resources are freed.
  204. * Note that NULL is a valid parameter value. This allows the function to be
  205. * called multiple times in a script.
  206. * @throws SqlsrvException
  207. *
  208. */
  209. function sqlsrv_free_stmt($stmt): void
  210. {
  211. error_clear_last();
  212. $result = \sqlsrv_free_stmt($stmt);
  213. if ($result === false) {
  214. throw SqlsrvException::createFromPhpError();
  215. }
  216. }
  217. /**
  218. * Gets field data from the currently selected row. Fields must be accessed in
  219. * order. Field indices start at 0.
  220. *
  221. * @param resource $stmt A statement resource returned by sqlsrv_query or
  222. * sqlsrv_execute.
  223. * @param int $fieldIndex The index of the field to be retrieved. Field indices start at 0. Fields
  224. * must be accessed in order. i.e. If you access field index 1, then field
  225. * index 0 will not be available.
  226. * @param int $getAsType The PHP data type for the returned field data. If this parameter is not
  227. * set, the field data will be returned as its default PHP data type.
  228. * For information about default PHP data types, see
  229. * Default PHP Data Types
  230. * in the Microsoft SQLSRV documentation.
  231. * @return mixed Returns data from the specified field on success.
  232. * @throws SqlsrvException
  233. *
  234. */
  235. function sqlsrv_get_field($stmt, int $fieldIndex, int $getAsType = null)
  236. {
  237. error_clear_last();
  238. if ($getAsType !== null) {
  239. $result = \sqlsrv_get_field($stmt, $fieldIndex, $getAsType);
  240. } else {
  241. $result = \sqlsrv_get_field($stmt, $fieldIndex);
  242. }
  243. if ($result === false) {
  244. throw SqlsrvException::createFromPhpError();
  245. }
  246. return $result;
  247. }
  248. /**
  249. * Makes the next result of the specified statement active. Results include result
  250. * sets, row counts, and output parameters.
  251. *
  252. * @param resource $stmt The statement on which the next result is being called.
  253. * @return bool|null Returns TRUE if the next result was successfully retrieved, FALSE if an error
  254. * occurred, and NULL if there are no more results to retrieve.
  255. * @throws SqlsrvException
  256. *
  257. */
  258. function sqlsrv_next_result($stmt): ?bool
  259. {
  260. error_clear_last();
  261. $result = \sqlsrv_next_result($stmt);
  262. if ($result === false) {
  263. throw SqlsrvException::createFromPhpError();
  264. }
  265. return $result;
  266. }
  267. /**
  268. * Retrieves the number of fields (columns) on a statement.
  269. *
  270. * @param resource $stmt The statement for which the number of fields is returned.
  271. * sqlsrv_num_fields can be called on a statement before
  272. * or after statement execution.
  273. * @return int Returns the number of fields on success.
  274. * @throws SqlsrvException
  275. *
  276. */
  277. function sqlsrv_num_fields($stmt): int
  278. {
  279. error_clear_last();
  280. $result = \sqlsrv_num_fields($stmt);
  281. if ($result === false) {
  282. throw SqlsrvException::createFromPhpError();
  283. }
  284. return $result;
  285. }
  286. /**
  287. * Retrieves the number of rows in a result set. This function requires that the
  288. * statement resource be created with a static or keyset cursor. For more information,
  289. * see sqlsrv_query, sqlsrv_prepare,
  290. * or Specifying a Cursor Type and Selecting Rows
  291. * in the Microsoft SQLSRV documentation.
  292. *
  293. * @param resource $stmt The statement for which the row count is returned. The statement resource
  294. * must be created with a static or keyset cursor. For more information, see
  295. * sqlsrv_query, sqlsrv_prepare, or
  296. * Specifying a Cursor Type and Selecting Rows
  297. * in the Microsoft SQLSRV documentation.
  298. * @return int Returns the number of rows retrieved on success.
  299. * If a forward cursor (the default) or dynamic cursor is used, FALSE is returned.
  300. * @throws SqlsrvException
  301. *
  302. */
  303. function sqlsrv_num_rows($stmt): int
  304. {
  305. error_clear_last();
  306. $result = \sqlsrv_num_rows($stmt);
  307. if ($result === false) {
  308. throw SqlsrvException::createFromPhpError();
  309. }
  310. return $result;
  311. }
  312. /**
  313. * Prepares a query for execution. This function is ideal for preparing a query
  314. * that will be executed multiple times with different parameter values.
  315. *
  316. * @param resource $conn A connection resource returned by sqlsrv_connect.
  317. * @param string $sql The string that defines the query to be prepared and executed.
  318. * @param array $params An array specifying parameter information when executing a parameterized
  319. * query. Array elements can be any of the following:
  320. *
  321. * A literal value
  322. * A PHP variable
  323. * An array with this structure:
  324. * array($value [, $direction [, $phpType [, $sqlType]]])
  325. *
  326. * The following table describes the elements in the array structure above:
  327. * @param array $options An array specifying query property options. The supported keys are described
  328. * in the following table:
  329. * @return resource Returns a statement resource on success.
  330. * @throws SqlsrvException
  331. *
  332. */
  333. function sqlsrv_prepare($conn, string $sql, array $params = null, array $options = null)
  334. {
  335. error_clear_last();
  336. if ($options !== null) {
  337. $result = \sqlsrv_prepare($conn, $sql, $params, $options);
  338. } elseif ($params !== null) {
  339. $result = \sqlsrv_prepare($conn, $sql, $params);
  340. } else {
  341. $result = \sqlsrv_prepare($conn, $sql);
  342. }
  343. if ($result === false) {
  344. throw SqlsrvException::createFromPhpError();
  345. }
  346. return $result;
  347. }
  348. /**
  349. * Prepares and executes a query.
  350. *
  351. * @param resource $conn A connection resource returned by sqlsrv_connect.
  352. * @param string $sql The string that defines the query to be prepared and executed.
  353. * @param array $params An array specifying parameter information when executing a parameterized query.
  354. * Array elements can be any of the following:
  355. *
  356. * A literal value
  357. * A PHP variable
  358. * An array with this structure:
  359. * array($value [, $direction [, $phpType [, $sqlType]]])
  360. *
  361. * The following table describes the elements in the array structure above:
  362. * @param array $options An array specifying query property options. The supported keys are described
  363. * in the following table:
  364. * @return resource Returns a statement resource on success.
  365. * @throws SqlsrvException
  366. *
  367. */
  368. function sqlsrv_query($conn, string $sql, array $params = null, array $options = null)
  369. {
  370. error_clear_last();
  371. if ($options !== null) {
  372. $result = \sqlsrv_query($conn, $sql, $params, $options);
  373. } elseif ($params !== null) {
  374. $result = \sqlsrv_query($conn, $sql, $params);
  375. } else {
  376. $result = \sqlsrv_query($conn, $sql);
  377. }
  378. if ($result === false) {
  379. throw SqlsrvException::createFromPhpError();
  380. }
  381. return $result;
  382. }
  383. /**
  384. * Rolls back a transaction that was begun with sqlsrv_begin_transaction
  385. * and returns the connection to auto-commit mode.
  386. *
  387. * @param resource $conn The connection resource returned by a call to sqlsrv_connect.
  388. * @throws SqlsrvException
  389. *
  390. */
  391. function sqlsrv_rollback($conn): void
  392. {
  393. error_clear_last();
  394. $result = \sqlsrv_rollback($conn);
  395. if ($result === false) {
  396. throw SqlsrvException::createFromPhpError();
  397. }
  398. }