DbiExtension.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. <?php
  2. /**
  3. * Contract for every database extension supported by phpMyAdmin
  4. *
  5. * @package PhpMyAdmin-DBI
  6. */
  7. namespace PhpMyAdmin\Dbi;
  8. /**
  9. * Contract for every database extension supported by phpMyAdmin
  10. *
  11. * @package PhpMyAdmin-DBI
  12. */
  13. interface DbiExtension
  14. {
  15. /**
  16. * connects to the database server
  17. *
  18. * @param string $user user name
  19. * @param string $password user password
  20. * @param array $server host/port/socket/persistent
  21. *
  22. * @return mixed false on error or a connection object on success
  23. */
  24. public function connect(
  25. $user, $password, array $server
  26. );
  27. /**
  28. * selects given database
  29. *
  30. * @param string $dbname database name to select
  31. * @param resource $link connection object
  32. *
  33. * @return boolean
  34. */
  35. public function selectDb($dbname, $link);
  36. /**
  37. * runs a query and returns the result
  38. *
  39. * @param string $query query to execute
  40. * @param resource $link connection object
  41. * @param int $options query options
  42. *
  43. * @return mixed result
  44. */
  45. public function realQuery($query, $link, $options);
  46. /**
  47. * Run the multi query and output the results
  48. *
  49. * @param resource $link connection object
  50. * @param string $query multi query statement to execute
  51. *
  52. * @return array|bool
  53. */
  54. public function realMultiQuery($link, $query);
  55. /**
  56. * returns array of rows with associative and numeric keys from $result
  57. *
  58. * @param object $result result set identifier
  59. *
  60. * @return array
  61. */
  62. public function fetchArray($result);
  63. /**
  64. * returns array of rows with associative keys from $result
  65. *
  66. * @param object $result result set identifier
  67. *
  68. * @return array
  69. */
  70. public function fetchAssoc($result);
  71. /**
  72. * returns array of rows with numeric keys from $result
  73. *
  74. * @param object $result result set identifier
  75. *
  76. * @return array
  77. */
  78. public function fetchRow($result);
  79. /**
  80. * Adjusts the result pointer to an arbitrary row in the result
  81. *
  82. * @param object $result database result
  83. * @param integer $offset offset to seek
  84. *
  85. * @return bool true on success, false on failure
  86. */
  87. public function dataSeek($result, $offset);
  88. /**
  89. * Frees memory associated with the result
  90. *
  91. * @param object $result database result
  92. *
  93. * @return void
  94. */
  95. public function freeResult($result);
  96. /**
  97. * Check if there are any more query results from a multi query
  98. *
  99. * @param resource $link the connection object
  100. *
  101. * @return bool true or false
  102. */
  103. public function moreResults($link);
  104. /**
  105. * Prepare next result from multi_query
  106. *
  107. * @param resource $link the connection object
  108. *
  109. * @return bool true or false
  110. */
  111. public function nextResult($link);
  112. /**
  113. * Store the result returned from multi query
  114. *
  115. * @param resource $link mysql link
  116. *
  117. * @return mixed false when empty results / result set when not empty
  118. */
  119. public function storeResult($link);
  120. /**
  121. * Returns a string representing the type of connection used
  122. *
  123. * @param resource $link mysql link
  124. *
  125. * @return string type of connection used
  126. */
  127. public function getHostInfo($link);
  128. /**
  129. * Returns the version of the MySQL protocol used
  130. *
  131. * @param resource $link mysql link
  132. *
  133. * @return integer version of the MySQL protocol used
  134. */
  135. public function getProtoInfo($link);
  136. /**
  137. * returns a string that represents the client library version
  138. *
  139. * @return string MySQL client library version
  140. */
  141. public function getClientInfo();
  142. /**
  143. * returns last error message or false if no errors occurred
  144. *
  145. * @param resource $link connection link
  146. *
  147. * @return string|bool $error or false
  148. */
  149. public function getError($link);
  150. /**
  151. * returns the number of rows returned by last query
  152. *
  153. * @param object $result result set identifier
  154. *
  155. * @return string|int
  156. */
  157. public function numRows($result);
  158. /**
  159. * returns the number of rows affected by last query
  160. *
  161. * @param resource $link the connection object
  162. *
  163. * @return int
  164. */
  165. public function affectedRows($link);
  166. /**
  167. * returns metainfo for fields in $result
  168. *
  169. * @param object $result result set identifier
  170. *
  171. * @return array meta info for fields in $result
  172. */
  173. public function getFieldsMeta($result);
  174. /**
  175. * return number of fields in given $result
  176. *
  177. * @param object $result result set identifier
  178. *
  179. * @return int field count
  180. */
  181. public function numFields($result);
  182. /**
  183. * returns the length of the given field $i in $result
  184. *
  185. * @param object $result result set identifier
  186. * @param int $i field
  187. *
  188. * @return int length of field
  189. */
  190. public function fieldLen($result, $i);
  191. /**
  192. * returns name of $i. field in $result
  193. *
  194. * @param object $result result set identifier
  195. * @param int $i field
  196. *
  197. * @return string name of $i. field in $result
  198. */
  199. public function fieldName($result, $i);
  200. /**
  201. * returns concatenated string of human readable field flags
  202. *
  203. * @param object $result result set identifier
  204. * @param int $i field
  205. *
  206. * @return string field flags
  207. */
  208. public function fieldFlags($result, $i);
  209. /**
  210. * returns properly escaped string for use in MySQL queries
  211. *
  212. * @param mixed $link database link
  213. * @param string $str string to be escaped
  214. *
  215. * @return string a MySQL escaped string
  216. */
  217. public function escapeString($link, $str);
  218. }