PageRenderTime 41ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/hphp/runtime/ext/mysql/ext_mysql.php

http://github.com/facebook/hiphop-php
PHP | 880 lines | 206 code | 57 blank | 617 comment | 0 complexity | dde830c01d42488815d6a4f3cff72557 MD5 | raw file
Possible License(s): LGPL-2.1, BSD-2-Clause, BSD-3-Clause, MPL-2.0-no-copyleft-exception, MIT, LGPL-2.0, Apache-2.0
  1. <?hh // partial
  2. /**
  3. * Get number of affected rows in previous MySQL operation
  4. *
  5. * @param resource $link_identifier -
  6. *
  7. * @return int - Returns the number of affected rows on success, and -1
  8. * if the last query failed. If the last query was a DELETE query with
  9. * no WHERE clause, all of the records will have been deleted from the
  10. * table but this function will return zero with MySQL versions prior to
  11. * 4.1.2. When using UPDATE, MySQL will not update columns where the
  12. * new value is the same as the old value. This creates the possibility
  13. * that mysql_affected_rows() may not actually equal the number of rows
  14. * matched, only the number of rows that were literally affected by the
  15. * query. The REPLACE statement first deletes the record with the same
  16. * primary key and then inserts the new record. This function returns the
  17. * number of deleted records plus the number of inserted records. In
  18. * the case of "INSERT ... ON DUPLICATE KEY UPDATE" queries, the return
  19. * value will be 1 if an insert was performed, or 2 for an update of an
  20. * existing row.
  21. */
  22. <<__Native>>
  23. function mysql_affected_rows(?resource $link_identifier = NULL): mixed;
  24. /**
  25. * Returns the name of the character set
  26. *
  27. * @param resource $link_identifier -
  28. *
  29. * @return string - Returns the default character set name for the
  30. * current connection.
  31. */
  32. <<__Native>>
  33. function mysql_client_encoding(?resource $link_identifier = NULL): mixed;
  34. /**
  35. * Close MySQL connection
  36. *
  37. * @param resource $link_identifier -
  38. *
  39. * @return bool -
  40. */
  41. <<__Native>>
  42. function mysql_close(?resource $link_identifier = NULL): bool;
  43. /**
  44. * Open a connection to a MySQL Server
  45. *
  46. * @param string $server - server The MySQL server. It can also include
  47. * a port number. e.g. "hostname:port" or a path to a local socket e.g.
  48. * ":/path/to/socket" for the localhost. If the PHP directive
  49. * mysql.default_host is undefined (default), then the default value is
  50. * 'localhost:3306'. In , this parameter is ignored and value
  51. * 'localhost:3306' is always used.
  52. * @param string $username - username The username. Default value is
  53. * defined by mysql.default_user. In , this parameter is ignored and the
  54. * name of the user that owns the server process is used.
  55. * @param string $password - password The password. Default value is
  56. * defined by mysql.default_password. In , this parameter is ignored and
  57. * empty password is used.
  58. * @param bool $new_link - new_link If a second call is made to
  59. * mysql_connect() with the same arguments, no new link will be
  60. * established, but instead, the link identifier of the already opened
  61. * link will be returned. The new_link parameter modifies this behavior
  62. * and makes mysql_connect() always open a new link, even if
  63. * mysql_connect() was called before with the same parameters. In , this
  64. * parameter is ignored.
  65. * @param int $client_flags - client_flags The client_flags parameter
  66. * can be a combination of the following constants: 128 (enable LOAD DATA
  67. * LOCAL handling), MYSQL_CLIENT_SSL, MYSQL_CLIENT_COMPRESS,
  68. * MYSQL_CLIENT_IGNORE_SPACE or MYSQL_CLIENT_INTERACTIVE. Read the
  69. * section about for further information. In , this parameter is
  70. * ignored.
  71. * @param array $conn_attrs - connection attribute associative array
  72. *
  73. * @return resource - Returns a MySQL link identifier on success.
  74. */
  75. <<__Native("NoFCallBuiltin")>>
  76. function mysql_connect(string $server = "",
  77. string $username = "",
  78. string $password = "",
  79. bool $new_link = false,
  80. int $client_flags = 0,
  81. int $connect_timeout_ms = -1,
  82. int $query_timeout_ms = -1,
  83. darray<string, string> $conn_attrs = darray[]): mixed;
  84. <<__Native("NoFCallBuiltin"), __HipHopSpecific>>
  85. function mysql_connect_with_db(string $server = "",
  86. string $username = "",
  87. string $password = "",
  88. string $database = "",
  89. bool $new_link = false,
  90. int $client_flags = 0,
  91. int $connect_timeout_ms = -1,
  92. int $query_timeout_ms = -1,
  93. darray<string, string> $conn_attrs = darray[]): mixed;
  94. <<__Native("NoFCallBuiltin")>>
  95. function mysql_connect_with_ssl(string $server,
  96. string $username,
  97. string $password,
  98. string $database = "",
  99. int $client_flags = 0,
  100. int $connect_timeout_ms = -1,
  101. int $query_timeout_ms = -1,
  102. ?MySSLContextProvider $ssl_context = null,
  103. darray<string, string> $conn_attrs = darray[]): mixed;
  104. /**
  105. * Create a MySQL database
  106. *
  107. * @param string $database_name - database_name The name of the
  108. * database being created.
  109. * @param resource $link_identifier -
  110. *
  111. * @return bool -
  112. */
  113. function mysql_create_db(string $database_name,
  114. ?resource $link_identifier = NULL): bool {
  115. throw new Exception(sprintf(
  116. '%s is not supported: %s',
  117. __FUNCTION__,
  118. 'Deprecated. Use mysql_query(CREATE DATABASE) instead.'
  119. ));
  120. }
  121. /**
  122. * Move internal result pointer
  123. *
  124. * @param resource $result -
  125. * @param int $row_number - row_number The desired row number of the
  126. * new result pointer.
  127. *
  128. * @return bool -
  129. */
  130. <<__Native>>
  131. function mysql_data_seek(resource $result,
  132. int $row_number): bool;
  133. /**
  134. * Retrieves database name from the call to
  135. *
  136. * @param resource $result - result The result pointer from a call to
  137. * mysql_list_dbs().
  138. * @param int $row - row The index into the result set.
  139. * @param mixed $field - field The field name.
  140. *
  141. * @return string - Returns the database name on success, and FALSE on
  142. * failure. If FALSE is returned, use mysql_error() to determine the
  143. * nature of the error.
  144. */
  145. function mysql_db_name(resource $result,
  146. mixed $row,
  147. mixed $field = NULL): mixed {
  148. return mysql_result($result, $row, $field);
  149. }
  150. /**
  151. * Selects a database and executes a query on it
  152. *
  153. * @param string $database - database The name of the database that
  154. * will be selected.
  155. * @param string $query - query The MySQL query. Data inside the
  156. * query should be properly escaped.
  157. * @param resource $link_identifier -
  158. *
  159. * @return resource - Returns a positive MySQL result resource to the
  160. * query result, or FALSE on error. The function also returns TRUE/FALSE
  161. * for INSERT/UPDATE/DELETE queries to indicate success/failure.
  162. */
  163. function mysql_db_query(string $database,
  164. string $query,
  165. ?resource $link_identifier = NULL): resource {
  166. throw new Exception(sprintf(
  167. '%s is not supported: %s',
  168. __FUNCTION__,
  169. 'Deprecated. Use mysql_query() instead.'
  170. ));
  171. }
  172. /**
  173. * Drop (delete) a MySQL database
  174. *
  175. * @param string $database_name - database_name The name of the
  176. * database that will be deleted.
  177. * @param resource $link_identifier -
  178. *
  179. * @return bool -
  180. */
  181. function mysql_drop_db(string $database_name,
  182. ?resource $link_identifier = NULL): bool {
  183. throw new Exception(sprintf(
  184. '%s is not supported: %s',
  185. __FUNCTION__,
  186. 'Deprecated. Use mysql_query(DROP DATABASE) instead.'
  187. ));
  188. }
  189. /**
  190. * Returns the numerical value of the error message from previous MySQL
  191. * operation
  192. *
  193. * @param resource $link_identifier -
  194. *
  195. * @return int - Returns the error number from the last MySQL function,
  196. * or 0 (zero) if no error occurred.
  197. */
  198. <<__Native>>
  199. function mysql_errno(?resource $link_identifier = NULL): mixed;
  200. /**
  201. * Returns the text of the error message from previous MySQL operation
  202. *
  203. * @param resource $link_identifier -
  204. *
  205. * @return string - Returns the error text from the last MySQL function,
  206. * or '' (empty string) if no error occurred.
  207. */
  208. <<__Native>>
  209. function mysql_error(?resource $link_identifier = NULL): mixed;
  210. /**
  211. * Escapes a string for use in a mysql_query
  212. *
  213. * @param string $unescaped_string - unescaped_string The string that
  214. * is to be escaped.
  215. *
  216. * @return string - Returns the escaped string.
  217. */
  218. <<__Native>>
  219. function mysql_escape_string(string $unescaped_string): string;
  220. /**
  221. * Fetch a result row as an associative array, a numeric array, or both
  222. *
  223. * @param resource $result -
  224. * @param int $result_type - result_type The type of array that is to
  225. * be fetched. It's a constant and can take the following values:
  226. * MYSQL_ASSOC, MYSQL_NUM, and MYSQL_BOTH.
  227. *
  228. * @return array - Returns an array of strings that corresponds to the
  229. * fetched row, or FALSE if there are no more rows. The type of returned
  230. * array depends on how result_type is defined. By using MYSQL_BOTH
  231. * (default), you'll get an array with both associative and number
  232. * indices. Using MYSQL_ASSOC, you only get associative indices (as
  233. * mysql_fetch_assoc() works), using MYSQL_NUM, you only get number
  234. * indices (as mysql_fetch_row() works). If two or more columns of the
  235. * result have the same field names, the last column will take
  236. * precedence. To access the other column(s) of the same name, you must
  237. * use the numeric index of the column or make an alias for the column.
  238. * For aliased columns, you cannot access the contents with the original
  239. * column name.
  240. */
  241. <<__Native>>
  242. function mysql_fetch_array(resource $result,
  243. int $result_type = MYSQL_BOTH): mixed;
  244. /**
  245. * Fetch a result row as an associative array
  246. *
  247. * @param resource $result -
  248. *
  249. * @return array - Returns an associative array of strings that
  250. * corresponds to the fetched row, or FALSE if there are no more rows.
  251. * If two or more columns of the result have the same field names, the
  252. * last column will take precedence. To access the other column(s) of the
  253. * same name, you either need to access the result with numeric indices
  254. * by using mysql_fetch_row() or add alias names. See the example at the
  255. * mysql_fetch_array() description about aliases.
  256. */
  257. function mysql_fetch_assoc(resource $result): mixed {
  258. return mysql_fetch_array($result, MYSQL_ASSOC);
  259. }
  260. /**
  261. * Get column information from a result and return as an object
  262. *
  263. * @param resource $result -
  264. * @param int $field_offset - field_offset The numerical field offset.
  265. * If the field offset is not specified, the next field that was not yet
  266. * retrieved by this function is retrieved. The field_offset starts at 0.
  267. *
  268. * @return object - Returns an object containing field information. The
  269. * properties of the object are: name - column name table - name
  270. * of the table the column belongs to, which is the alias name if one is
  271. * defined max_length - maximum length of the column not_null - 1
  272. * if the column cannot be NULL primary_key - 1 if the column is a
  273. * primary key unique_key - 1 if the column is a unique key
  274. * multiple_key - 1 if the column is a non-unique key numeric - 1 if
  275. * the column is numeric blob - 1 if the column is a BLOB type -
  276. * the type of the column unsigned - 1 if the column is unsigned
  277. * zerofill - 1 if the column is zero-filled
  278. */
  279. <<__Native>>
  280. function mysql_fetch_field(resource $result,
  281. int $field_offset = -1): mixed;
  282. /**
  283. * Get the length of each output in a result
  284. *
  285. * @param resource $result -
  286. *
  287. * @return array - An array of lengths on success.
  288. */
  289. <<__Native>>
  290. function mysql_fetch_lengths(resource $result): mixed;
  291. /**
  292. * Fetch a result row as an object
  293. *
  294. * @param resource $result -
  295. * @param string $class_name - class_name The name of the class to
  296. * instantiate, set the properties of and return. If not specified, a
  297. * stdClass object is returned.
  298. * @param array $params - params An optional array of parameters to
  299. * pass to the constructor for class_name objects.
  300. *
  301. * @return object - Returns an object with string properties that
  302. * correspond to the fetched row, or FALSE if there are no more rows.
  303. */
  304. <<__Native>>
  305. function mysql_fetch_object(mixed $result,
  306. string $class_name = 'stdClass',
  307. ?array $params = null): mixed;
  308. /**
  309. * Used with mysql_multi_query() to return a mysql result for the current
  310. * iterated query.
  311. *
  312. * @param resource $link_identifier - The MySQL connection. If the link
  313. * identifier is not specified, the last link
  314. * opened by mysql_connect() is assumed. If
  315. * no such link is found, it will try to
  316. * create one as if mysql_connect() was
  317. * called with no arguments. If no connection
  318. * is found or established, an E_WARNING
  319. * level error is generated.
  320. *
  321. * @return mixed - Returns a resource or a boolean
  322. */
  323. <<__Native, __HipHopSpecific>>
  324. function mysql_fetch_result(?resource $link_identifier = NULL): mixed;
  325. /**
  326. * Get a result row as an enumerated array
  327. *
  328. * @param resource $result -
  329. *
  330. * @return array - Returns an numerical array of strings that corresponds
  331. * to the fetched row, or FALSE if there are no more rows.
  332. * mysql_fetch_row() fetches one row of data from the result associated
  333. * with the specified result identifier. The row is returned as an array.
  334. * Each result column is stored in an array offset, starting at offset 0.
  335. */
  336. function mysql_fetch_row(resource $result): mixed {
  337. return mysql_fetch_array($result, MYSQL_NUM);
  338. }
  339. /**
  340. * Get the flags associated with the specified field in a result
  341. *
  342. * @param resource $result -
  343. * @param int $field_offset -
  344. *
  345. * @return string - Returns a string of flags associated with the result.
  346. * The following flags are reported, if your version of MySQL is
  347. * current enough to support them: "not_null", "primary_key",
  348. * "unique_key", "multiple_key", "blob", "unsigned", "zerofill",
  349. * "binary", "enum", "auto_increment" and "timestamp".
  350. */
  351. <<__Native>>
  352. function mysql_field_flags(resource $result,
  353. int $field_offset): mixed;
  354. /**
  355. * Returns the length of the specified field
  356. *
  357. * @param resource $result -
  358. * @param int $field_offset -
  359. *
  360. * @return int - The length of the specified field index on success.
  361. */
  362. <<__Native>>
  363. function mysql_field_len(resource $result,
  364. int $field_offset): mixed;
  365. /**
  366. * Get the name of the specified field in a result
  367. *
  368. * @param resource $result -
  369. * @param int $field_offset -
  370. *
  371. * @return string - The name of the specified field index on success.
  372. */
  373. <<__Native>>
  374. function mysql_field_name(resource $result,
  375. int $field_offset): mixed;
  376. /**
  377. * Set result pointer to a specified field offset
  378. *
  379. * @param resource $result -
  380. * @param int $field_offset -
  381. *
  382. * @return bool -
  383. */
  384. <<__Native>>
  385. function mysql_field_seek(resource $result,
  386. int $field_offset): bool;
  387. /**
  388. * Get name of the table the specified field is in
  389. *
  390. * @param resource $result -
  391. * @param int $field_offset -
  392. *
  393. * @return string - The name of the table on success.
  394. */
  395. <<__Native>>
  396. function mysql_field_table(resource $result,
  397. int $field_offset): mixed;
  398. /**
  399. * Get the type of the specified field in a result
  400. *
  401. * @param resource $result -
  402. * @param int $field_offset -
  403. *
  404. * @return string - The returned field type will be one of "int", "real",
  405. * "string", "blob", and others as detailed in the MySQL documentation.
  406. */
  407. <<__Native>>
  408. function mysql_field_type(resource $result,
  409. int $field_offset): mixed;
  410. /**
  411. * Free result memory
  412. *
  413. * @param resource $result -
  414. *
  415. * @return bool - If a non-resource is used for the result, an error of
  416. * level E_WARNING will be emitted. It's worth noting that mysql_query()
  417. * only returns a resource for SELECT, SHOW, EXPLAIN, and DESCRIBE
  418. * queries.
  419. */
  420. <<__Native>>
  421. function mysql_free_result(resource $result): bool;
  422. /**
  423. * Get MySQL client info
  424. *
  425. * @return string - The MySQL client version.
  426. */
  427. <<__Native>>
  428. function mysql_get_client_info(): string;
  429. /**
  430. * Get MySQL host info
  431. *
  432. * @param resource $link_identifier -
  433. *
  434. * @return string - Returns a string describing the type of MySQL
  435. * connection in use for the connection.
  436. */
  437. <<__Native>>
  438. function mysql_get_host_info(?resource $link_identifier = NULL): mixed;
  439. /**
  440. * Get MySQL protocol info
  441. *
  442. * @param resource $link_identifier -
  443. *
  444. * @return int - Returns the MySQL protocol on success.
  445. */
  446. <<__Native>>
  447. function mysql_get_proto_info(?resource $link_identifier = NULL): mixed;
  448. /**
  449. * Get MySQL server info
  450. *
  451. * @param resource $link_identifier -
  452. *
  453. * @return string - Returns the MySQL server version on success.
  454. */
  455. <<__Native>>
  456. function mysql_get_server_info(?resource $link_identifier = NULL): mixed;
  457. /**
  458. * Get information about the most recent query
  459. *
  460. * @param resource $link_identifier -
  461. *
  462. * @return string - Returns information about the statement on success,
  463. * or FALSE on failure. See the example below for which statements
  464. * provide information, and what the returned value may look like.
  465. * Statements that are not listed will return FALSE.
  466. */
  467. <<__Native>>
  468. function mysql_info(?resource $link_identifier = NULL): mixed;
  469. /**
  470. * Get the ID generated in the last query
  471. *
  472. * @param resource $link_identifier -
  473. *
  474. * @return int - The ID generated for an AUTO_INCREMENT column by the
  475. * previous query on success, 0 if the previous query does not generate
  476. * an AUTO_INCREMENT value, or FALSE if no MySQL connection was
  477. * established.
  478. */
  479. <<__Native>>
  480. function mysql_insert_id(?resource $link_identifier = NULL): mixed;
  481. /**
  482. * List databases available on a MySQL server
  483. *
  484. * @param resource $link_identifier -
  485. *
  486. * @return resource - Returns a result pointer resource on success, or
  487. * FALSE on failure. Use the mysql_tablename() function to traverse this
  488. * result pointer, or any function for result tables, such as
  489. * mysql_fetch_array().
  490. */
  491. <<__Native>>
  492. function mysql_list_dbs(?resource $link_identifier = NULL): mixed;
  493. /**
  494. * List MySQL table fields
  495. *
  496. * @param string $database_name - database_name The name of the
  497. * database that's being queried.
  498. * @param string $table_name - table_name The name of the table that's
  499. * being queried.
  500. * @param resource $link_identifier -
  501. *
  502. * @return resource - A result pointer resource on success, or FALSE on
  503. * failure. The returned result can be used with mysql_field_flags(),
  504. * mysql_field_len(), mysql_field_name() mysql_field_type().
  505. */
  506. function mysql_list_fields(string $database_name,
  507. string $table_name,
  508. ?resource $link_identifier = NULL): resource {
  509. throw new Exception(sprintf(
  510. '%s is not supported: %s',
  511. __FUNCTION__,
  512. 'Deprecated. Use mysql_query(SHOW COLUMNS FROM table [LIKE \'name\']) ' .
  513. 'instead.'
  514. ));
  515. }
  516. /**
  517. * List MySQL processes
  518. *
  519. * @param resource $link_identifier -
  520. *
  521. * @return resource - A result pointer resource on success.
  522. */
  523. <<__Native>>
  524. function mysql_list_processes(?resource $link_identifier = NULL): mixed;
  525. /**
  526. * List tables in a MySQL database
  527. *
  528. * @param string $database - database The name of the database
  529. * @param resource $link_identifier -
  530. *
  531. * @return resource - A result pointer resource on success. Use the
  532. * mysql_tablename() function to traverse this result pointer, or any
  533. * function for result tables, such as mysql_fetch_array().
  534. */
  535. <<__Native>>
  536. function mysql_list_tables(string $database,
  537. ?resource $link_identifier = NULL): mixed;
  538. /**
  539. * Used with mysql_multi_query() to check if there are more result sets to be
  540. * returned.
  541. *
  542. * @param resource $link_identifier - The MySQL connection. If the link
  543. * identifier is not specified, the last link
  544. * opened by mysql_connect() is assumed. If
  545. * no such link is found, it will try to
  546. * create one as if mysql_connect() was
  547. * called with no arguments. If no connection
  548. * is found or established, an E_WARNING
  549. * level error is generated.
  550. *
  551. * @return bool - True if there is at least one more item in the result set.
  552. */
  553. <<__Native, __HipHopSpecific>>
  554. function mysql_more_results(?resource $link_identifier = NULL): bool;
  555. /**
  556. * mysql_multi_query() executes one or more queries separated by a ; to the
  557. * currently active database on the server that's associated with the specified
  558. * link_identifier.
  559. *
  560. * @param string $query - An SQL query
  561. * The query string should not end with a
  562. * semicolon. Data inside the query should be
  563. * properly escaped.
  564. * @param resource $link_identifier - The MySQL connection. If the link
  565. * identifier is not specified, the last link
  566. * opened by mysql_connect() is assumed. If
  567. * no such link is found, it will try to
  568. * create one as if mysql_connect() was
  569. * called with no arguments. If no connection
  570. * is found or established, an E_WARNING
  571. * level error is generated.
  572. *
  573. * @return mixed - This is a fb specific query so behaviour is a little random
  574. * at the moment.
  575. */
  576. <<__Native, __HipHopSpecific>>
  577. function mysql_multi_query(string $query,
  578. ?resource $link_identifier = NULL): mixed;
  579. /**
  580. * Used with mysql_multi_query() to move the result set on one.
  581. *
  582. * @param resource $link_identifier - The MySQL connection. If the link
  583. * identifier is not specified, the last link
  584. * opened by mysql_connect() is assumed. If
  585. * no such link is found, it will try to
  586. * create one as if mysql_connect() was
  587. * called with no arguments. If no connection
  588. * is found or established, an E_WARNING
  589. * level error is generated.
  590. *
  591. * @return int - 0 - Query succeeded, more results coming. -1 - Query succeeded,
  592. * no more results coming. >0 - query failed, value is error code.
  593. */
  594. <<__Native, __HipHopSpecific>>
  595. function mysql_next_result(?resource $link_identifier = NULL): int;
  596. /**
  597. * Get number of fields in result
  598. *
  599. * @param resource $result -
  600. *
  601. * @return int - Returns the number of fields in the result set resource
  602. * on success.
  603. */
  604. <<__Native>>
  605. function mysql_num_fields(resource $result): mixed;
  606. /**
  607. * Get number of rows in result
  608. *
  609. * @param resource $result -
  610. *
  611. * @return int - The number of rows in a result set on success.
  612. */
  613. <<__Native>>
  614. function mysql_num_rows(resource $result): mixed;
  615. /**
  616. * Open a persistent connection to a MySQL server
  617. *
  618. * @param string $server - server The MySQL server. It can also include
  619. * a port number. e.g. "hostname:port" or a path to a local socket e.g.
  620. * ":/path/to/socket" for the localhost. If the PHP directive
  621. * mysql.default_host is undefined (default), then the default value is
  622. * 'localhost:3306'
  623. * @param string $username - username The username. Default value is
  624. * the name of the user that owns the server process.
  625. * @param string $password - password The password. Default value is an
  626. * empty password.
  627. * @param int $client_flags - client_flags The client_flags parameter
  628. * can be a combination of the following constants: 128 (enable LOAD DATA
  629. * LOCAL handling), MYSQL_CLIENT_SSL, MYSQL_CLIENT_COMPRESS,
  630. * MYSQL_CLIENT_IGNORE_SPACE or MYSQL_CLIENT_INTERACTIVE.
  631. *
  632. * @return resource - Returns a MySQL persistent link identifier on
  633. * success, or FALSE on failure.
  634. */
  635. <<__Native>>
  636. function mysql_pconnect(string $server = '',
  637. string $username = '',
  638. string $password = '',
  639. int $client_flags = 0,
  640. int $connect_timeout_ms = -1,
  641. int $query_timeout_ms = -1,
  642. darray<string, string> $conn_attrs = darray[]): mixed;
  643. <<__Native, __HipHopSpecific>>
  644. function mysql_pconnect_with_db(string $server = '',
  645. string $username = '',
  646. string $password = '',
  647. string $database = '',
  648. int $client_flags = 0,
  649. int $connect_timeout_ms = -1,
  650. int $query_timeout_ms = -1,
  651. darray<string, string> $conn_attrs = darray[]): mixed;
  652. /**
  653. * Ping a server connection or reconnect if there is no connection
  654. *
  655. * @param resource $link_identifier -
  656. *
  657. * @return bool - Returns TRUE if the connection to the server MySQL
  658. * server is working, otherwise FALSE.
  659. */
  660. <<__Native>>
  661. function mysql_ping(?resource $link_identifier = NULL): ?bool;
  662. /**
  663. * Send a MySQL query
  664. *
  665. * @param string $query - query An SQL query The query string should
  666. * not end with a semicolon. Data inside the query should be properly
  667. * escaped.
  668. * @param resource $link_identifier -
  669. *
  670. * @return resource - For SELECT, SHOW, DESCRIBE, EXPLAIN and other
  671. * statements returning resultset, mysql_query() returns a resource on
  672. * success, or FALSE on error. For other type of SQL statements,
  673. * INSERT, UPDATE, DELETE, DROP, etc, mysql_query() returns TRUE on
  674. * success or FALSE on error. The returned result resource should be
  675. * passed to mysql_fetch_array(), and other functions for dealing with
  676. * result tables, to access the returned data. Use mysql_num_rows() to
  677. * find out how many rows were returned for a SELECT statement or
  678. * mysql_affected_rows() to find out how many rows were affected by a
  679. * DELETE, INSERT, REPLACE, or UPDATE statement. mysql_query() will
  680. * also fail and return FALSE if the user does not have permission to
  681. * access the table(s) referenced by the query.
  682. */
  683. <<__Native("NoFCallBuiltin")>>
  684. function mysql_query(string $query,
  685. ?resource $link_identifier = NULL): mixed;
  686. /**
  687. * Escapes special characters in a string for use in an SQL statement
  688. *
  689. * @param string $unescaped_string - unescaped_string The string that
  690. * is to be escaped.
  691. * @param resource $link_identifier -
  692. *
  693. * @return string - Returns the escaped string, or FALSE on error.
  694. */
  695. <<__Native>>
  696. function mysql_real_escape_string(string $unescaped_string,
  697. ?resource $link_identifier = NULL): mixed;
  698. /**
  699. * Get result data
  700. *
  701. * @param resource $result -
  702. * @param int $row - row The row number from the result that's being
  703. * retrieved. Row numbers start at 0.
  704. * @param mixed $field - field The name or offset of the field being
  705. * retrieved. It can be the field's offset, the field's name, or the
  706. * field's table dot field name (tablename.fieldname). If the column name
  707. * has been aliased ('select foo as bar from...'), use the alias instead
  708. * of the column name. If undefined, the first field is retrieved.
  709. *
  710. * @return string - The contents of one cell from a MySQL result set on
  711. * success, or FALSE on failure.
  712. */
  713. <<__Native>>
  714. function mysql_result(resource $result,
  715. int $row,
  716. mixed $field = 0): mixed;
  717. /**
  718. * Select a MySQL database
  719. *
  720. * @param string $database_name - database_name The name of the
  721. * database that is to be selected.
  722. * @param resource $link_identifier -
  723. *
  724. * @return bool -
  725. */
  726. <<__Native>>
  727. function mysql_select_db(string $database_name,
  728. ?resource $link_identifier = NULL): bool;
  729. /**
  730. * Sets the client character set
  731. *
  732. * @param string $charset - charset A valid character set name.
  733. * @param resource $link_identifier -
  734. *
  735. * @return bool -
  736. */
  737. <<__Native>>
  738. function mysql_set_charset(string $charset,
  739. ?resource $link_identifier = NULL): ?bool;
  740. /**
  741. * Sets query timeout for a connection
  742. *
  743. * @param int $query_timeout_ms - How many milli-seconds to wait for an SQL
  744. * query
  745. * @param resource $link_identifier - Which connection to set to. If absent,
  746. * default or current connection will be
  747. * applied to.
  748. *
  749. * @return bool
  750. */
  751. <<__Native, __HipHopSpecific>>
  752. function mysql_set_timeout(int $query_timeout_ms,
  753. ?resource $link_identifier = NULL): bool;
  754. /**
  755. * Get current system status
  756. *
  757. * @param resource $link_identifier -
  758. *
  759. * @return string - Returns a string with the status for uptime, threads,
  760. * queries, open tables, flush tables and queries per second. For a
  761. * complete list of other status variables, you have to use the SHOW
  762. * STATUS SQL command. If link_identifier is invalid, NULL is returned.
  763. */
  764. <<__Native>>
  765. function mysql_stat(?resource $link_identifier = NULL): mixed;
  766. /**
  767. * Get table name of field
  768. *
  769. * @param resource $result - result A result pointer resource that's
  770. * returned from mysql_list_tables().
  771. * @param int $i - i The integer index (row/table number)
  772. *
  773. * @return string - The name of the table on success. Use the
  774. * mysql_tablename() function to traverse this result pointer, or any
  775. * function for result tables, such as mysql_fetch_array().
  776. */
  777. function mysql_tablename(resource $result,
  778. int $i): mixed {
  779. return mysql_result($result, $i);
  780. }
  781. /**
  782. * Return the current thread ID
  783. *
  784. * @param resource $link_identifier -
  785. *
  786. * @return int - The thread ID on success.
  787. */
  788. <<__Native>>
  789. function mysql_thread_id(?resource $link_identifier = NULL): mixed;
  790. /**
  791. * Send an SQL query to MySQL without fetching and buffering the result rows.
  792. *
  793. * @param string $query - query The SQL query to execute. Data inside
  794. * the query should be properly escaped.
  795. * @param resource $link_identifier -
  796. *
  797. * @return resource - For SELECT, SHOW, DESCRIBE or EXPLAIN statements,
  798. * mysql_unbuffered_query() returns a resource on success, or FALSE on
  799. * error. For other type of SQL statements, UPDATE, DELETE, DROP, etc,
  800. * mysql_unbuffered_query() returns TRUE on success or FALSE on error.
  801. */
  802. <<__Native>>
  803. function mysql_unbuffered_query(string $query,
  804. ?resource $link_identifier = NULL): mixed;
  805. /**
  806. * Returns the number of errors generated during execution of the previous SQL
  807. * statement. To retrieve warning messages you can use the SQL command SHOW
  808. * WARNINGS [limit row_count].
  809. *
  810. * @param resource $link_identifier - The MySQL connection. If the link
  811. * identifier is not specified, the last link
  812. * opened by mysql_connect() is assumed. If
  813. * no such link is found, it will try to
  814. * create one as if mysql_connect() was
  815. * called with no arguments. If no connection
  816. * is found or established, an E_WARNING
  817. * level error is generated.
  818. *
  819. * @return int - Returns the number of warnings from the last MySQL function, or
  820. * 0 (zero) if no warnings occurred.
  821. */
  822. <<__Native, __HipHopSpecific>>
  823. function mysql_warning_count(?resource $link_identifier = NULL): mixed;