Exceptions
5 days ago
apache.php
5 days ago
apcu.php
5 days ago
array.php
5 days ago
bzip2.php
5 days ago
calendar.php
5 days ago
classobj.php
5 days ago
com.php
5 days ago
cubrid.php
5 days ago
curl.php
5 days ago
datetime.php
5 days ago
dir.php
5 days ago
eio.php
5 days ago
errorfunc.php
5 days ago
exec.php
5 days ago
fileinfo.php
5 days ago
filesystem.php
5 days ago
filter.php
5 days ago
fpm.php
5 days ago
ftp.php
5 days ago
funchand.php
5 days ago
functionsList.php
5 days ago
gmp.php
5 days ago
gnupg.php
5 days ago
hash.php
5 days ago
ibase.php
5 days ago
ibmDb2.php
5 days ago
iconv.php
5 days ago
image.php
5 days ago
imap.php
5 days ago
info.php
5 days ago
ingres-ii.php
5 days ago
inotify.php
5 days ago
json.php
5 days ago
ldap.php
5 days ago
libxml.php
5 days ago
lzf.php
5 days ago
mailparse.php
5 days ago
mbstring.php
5 days ago
misc.php
5 days ago
msql.php
5 days ago
mysql.php
5 days ago
mysqli.php
5 days ago
mysqlndMs.php
5 days ago
mysqlndQc.php
5 days ago
network.php
5 days ago
oci8.php
5 days ago
opcache.php
5 days ago
openssl.php
5 days ago
outcontrol.php
5 days ago
password.php
5 days ago
pcntl.php
5 days ago
pcre.php
5 days ago
pdf.php
5 days ago
pgsql.php
5 days ago
posix.php
5 days ago
ps.php
5 days ago
pspell.php
5 days ago
readline.php
5 days ago
rpminfo.php
5 days ago
rrd.php
5 days ago
sem.php
5 days ago
session.php
5 days ago
shmop.php
5 days ago
simplexml.php
5 days ago
sockets.php
5 days ago
sodium.php
5 days ago
solr.php
5 days ago
spl.php
5 days ago
sqlsrv.php
5 days ago
ssdeep.php
5 days ago
ssh2.php
5 days ago
stream.php
5 days ago
strings.php
5 days ago
swoole.php
5 days ago
uodbc.php
5 days ago
uopz.php
5 days ago
url.php
5 days ago
var.php
5 days ago
xdiff.php
5 days ago
xml.php
5 days ago
xmlrpc.php
5 days ago
yaml.php
5 days ago
yaz.php
5 days ago
zip.php
5 days ago
zlib.php
5 days ago
msql.php
413 lines
| 1 | <?php |
| 2 | |
| 3 | namespace ProfilePressVendor\Safe; |
| 4 | |
| 5 | use ProfilePressVendor\Safe\Exceptions\MsqlException; |
| 6 | /** |
| 7 | * Returns number of affected rows by the last SELECT, UPDATE or DELETE |
| 8 | * query associated with result. |
| 9 | * |
| 10 | * @param resource $result The result resource that |
| 11 | * is being evaluated. This result comes from a call to |
| 12 | * msql_query. |
| 13 | * @return int Returns the number of affected rows on success. |
| 14 | * @throws MsqlException |
| 15 | * |
| 16 | */ |
| 17 | function msql_affected_rows($result): int |
| 18 | { |
| 19 | error_clear_last(); |
| 20 | $result = \ProfilePressVendor\msql_affected_rows($result); |
| 21 | if ($result === \false) { |
| 22 | throw MsqlException::createFromPhpError(); |
| 23 | } |
| 24 | return $result; |
| 25 | } |
| 26 | /** |
| 27 | * msql_close closes the non-persistent connection to |
| 28 | * the mSQL server that's associated with the specified link identifier. |
| 29 | * |
| 30 | * Using msql_close isn't usually necessary, as |
| 31 | * non-persistent open links are automatically closed at the end of the |
| 32 | * script's execution. See also freeing resources. |
| 33 | * |
| 34 | * @param resource|null $link_identifier The mSQL connection. |
| 35 | * If not specified, the last link opened by msql_connect |
| 36 | * is assumed. If no such link is found, the function will try to establish a |
| 37 | * link as if msql_connect was called, and use it. |
| 38 | * @throws MsqlException |
| 39 | * |
| 40 | */ |
| 41 | function msql_close($link_identifier = null): void |
| 42 | { |
| 43 | error_clear_last(); |
| 44 | if ($link_identifier !== null) { |
| 45 | $result = \ProfilePressVendor\msql_close($link_identifier); |
| 46 | } else { |
| 47 | $result = \ProfilePressVendor\msql_close(); |
| 48 | } |
| 49 | if ($result === \false) { |
| 50 | throw MsqlException::createFromPhpError(); |
| 51 | } |
| 52 | } |
| 53 | /** |
| 54 | * msql_connect establishes a connection to a mSQL |
| 55 | * server. |
| 56 | * |
| 57 | * If a second call is made to msql_connect with |
| 58 | * the same arguments, no new link will be established, but instead, the |
| 59 | * link identifier of the already opened link will be returned. |
| 60 | * |
| 61 | * The link to the server will be closed as soon as the execution of the |
| 62 | * script ends, unless it's closed earlier by explicitly calling |
| 63 | * msql_close. |
| 64 | * |
| 65 | * @param string $hostname The hostname can also include a port number. e.g. |
| 66 | * hostname,port. |
| 67 | * |
| 68 | * If not specified, the connection is established by the means of a Unix |
| 69 | * domain socket, being then more efficient then a localhost TCP socket |
| 70 | * connection. |
| 71 | * |
| 72 | * While this function will accept a colon (:) as a |
| 73 | * host/port separator, a comma (,) is the preferred |
| 74 | * method. |
| 75 | * @return resource Returns a positive mSQL link identifier on success. |
| 76 | * @throws MsqlException |
| 77 | * |
| 78 | */ |
| 79 | function msql_connect(string $hostname = null) |
| 80 | { |
| 81 | error_clear_last(); |
| 82 | if ($hostname !== null) { |
| 83 | $result = \ProfilePressVendor\msql_connect($hostname); |
| 84 | } else { |
| 85 | $result = \ProfilePressVendor\msql_connect(); |
| 86 | } |
| 87 | if ($result === \false) { |
| 88 | throw MsqlException::createFromPhpError(); |
| 89 | } |
| 90 | return $result; |
| 91 | } |
| 92 | /** |
| 93 | * msql_create_db attempts to create a new database on |
| 94 | * the mSQL server. |
| 95 | * |
| 96 | * @param string $database_name The name of the mSQL database. |
| 97 | * @param resource|null $link_identifier The mSQL connection. |
| 98 | * If not specified, the last link opened by msql_connect |
| 99 | * is assumed. If no such link is found, the function will try to establish a |
| 100 | * link as if msql_connect was called, and use it. |
| 101 | * @throws MsqlException |
| 102 | * |
| 103 | */ |
| 104 | function msql_create_db(string $database_name, $link_identifier = null): void |
| 105 | { |
| 106 | error_clear_last(); |
| 107 | if ($link_identifier !== null) { |
| 108 | $result = \ProfilePressVendor\msql_create_db($database_name, $link_identifier); |
| 109 | } else { |
| 110 | $result = \ProfilePressVendor\msql_create_db($database_name); |
| 111 | } |
| 112 | if ($result === \false) { |
| 113 | throw MsqlException::createFromPhpError(); |
| 114 | } |
| 115 | } |
| 116 | /** |
| 117 | * msql_data_seek moves the internal row |
| 118 | * pointer of the mSQL result associated with the specified query |
| 119 | * identifier to point to the specified row number. The next call |
| 120 | * to msql_fetch_row would return that |
| 121 | * row. |
| 122 | * |
| 123 | * @param resource $result The result resource that |
| 124 | * is being evaluated. This result comes from a call to |
| 125 | * msql_query. |
| 126 | * @param int $row_number The seeked row number. |
| 127 | * @throws MsqlException |
| 128 | * |
| 129 | */ |
| 130 | function msql_data_seek($result, int $row_number): void |
| 131 | { |
| 132 | error_clear_last(); |
| 133 | $result = \ProfilePressVendor\msql_data_seek($result, $row_number); |
| 134 | if ($result === \false) { |
| 135 | throw MsqlException::createFromPhpError(); |
| 136 | } |
| 137 | } |
| 138 | /** |
| 139 | * msql_db_query selects a database and executes a query |
| 140 | * on it. |
| 141 | * |
| 142 | * @param string $database The name of the mSQL database. |
| 143 | * @param string $query The SQL query. |
| 144 | * @param resource|null $link_identifier The mSQL connection. |
| 145 | * If not specified, the last link opened by msql_connect |
| 146 | * is assumed. If no such link is found, the function will try to establish a |
| 147 | * link as if msql_connect was called, and use it. |
| 148 | * @return resource Returns a positive mSQL query identifier to the query result. |
| 149 | * @throws MsqlException |
| 150 | * |
| 151 | */ |
| 152 | function msql_db_query(string $database, string $query, $link_identifier = null) |
| 153 | { |
| 154 | error_clear_last(); |
| 155 | if ($link_identifier !== null) { |
| 156 | $result = \ProfilePressVendor\msql_db_query($database, $query, $link_identifier); |
| 157 | } else { |
| 158 | $result = \ProfilePressVendor\msql_db_query($database, $query); |
| 159 | } |
| 160 | if ($result === \false) { |
| 161 | throw MsqlException::createFromPhpError(); |
| 162 | } |
| 163 | return $result; |
| 164 | } |
| 165 | /** |
| 166 | * msql_drop_db attempts to drop (remove) a database |
| 167 | * from the mSQL server. |
| 168 | * |
| 169 | * @param string $database_name The name of the database. |
| 170 | * @param resource|null $link_identifier The mSQL connection. |
| 171 | * If not specified, the last link opened by msql_connect |
| 172 | * is assumed. If no such link is found, the function will try to establish a |
| 173 | * link as if msql_connect was called, and use it. |
| 174 | * @throws MsqlException |
| 175 | * |
| 176 | */ |
| 177 | function msql_drop_db(string $database_name, $link_identifier = null): void |
| 178 | { |
| 179 | error_clear_last(); |
| 180 | if ($link_identifier !== null) { |
| 181 | $result = \ProfilePressVendor\msql_drop_db($database_name, $link_identifier); |
| 182 | } else { |
| 183 | $result = \ProfilePressVendor\msql_drop_db($database_name); |
| 184 | } |
| 185 | if ($result === \false) { |
| 186 | throw MsqlException::createFromPhpError(); |
| 187 | } |
| 188 | } |
| 189 | /** |
| 190 | * msql_field_len returns the length of the specified |
| 191 | * field. |
| 192 | * |
| 193 | * @param resource $result The result resource that |
| 194 | * is being evaluated. This result comes from a call to |
| 195 | * msql_query. |
| 196 | * @param int $field_offset The numerical field offset. The |
| 197 | * field_offset starts at 1. |
| 198 | * @return int Returns the length of the specified field. |
| 199 | * @throws MsqlException |
| 200 | * |
| 201 | */ |
| 202 | function msql_field_len($result, int $field_offset): int |
| 203 | { |
| 204 | error_clear_last(); |
| 205 | $result = \ProfilePressVendor\msql_field_len($result, $field_offset); |
| 206 | if ($result === \false) { |
| 207 | throw MsqlException::createFromPhpError(); |
| 208 | } |
| 209 | return $result; |
| 210 | } |
| 211 | /** |
| 212 | * msql_field_name gets the name of the specified field |
| 213 | * index. |
| 214 | * |
| 215 | * @param resource $result The result resource that |
| 216 | * is being evaluated. This result comes from a call to |
| 217 | * msql_query. |
| 218 | * @param int $field_offset The numerical field offset. The |
| 219 | * field_offset starts at 1. |
| 220 | * @return string The name of the field. |
| 221 | * @throws MsqlException |
| 222 | * |
| 223 | */ |
| 224 | function msql_field_name($result, int $field_offset): string |
| 225 | { |
| 226 | error_clear_last(); |
| 227 | $result = \ProfilePressVendor\msql_field_name($result, $field_offset); |
| 228 | if ($result === \false) { |
| 229 | throw MsqlException::createFromPhpError(); |
| 230 | } |
| 231 | return $result; |
| 232 | } |
| 233 | /** |
| 234 | * Seeks to the specified field offset. If the next call to |
| 235 | * msql_fetch_field won't include a field offset, this |
| 236 | * field would be returned. |
| 237 | * |
| 238 | * @param resource $result The result resource that |
| 239 | * is being evaluated. This result comes from a call to |
| 240 | * msql_query. |
| 241 | * @param int $field_offset The numerical field offset. The |
| 242 | * field_offset starts at 1. |
| 243 | * @throws MsqlException |
| 244 | * |
| 245 | */ |
| 246 | function msql_field_seek($result, int $field_offset): void |
| 247 | { |
| 248 | error_clear_last(); |
| 249 | $result = \ProfilePressVendor\msql_field_seek($result, $field_offset); |
| 250 | if ($result === \false) { |
| 251 | throw MsqlException::createFromPhpError(); |
| 252 | } |
| 253 | } |
| 254 | /** |
| 255 | * Returns the name of the table that the specified field is in. |
| 256 | * |
| 257 | * @param resource $result The result resource that |
| 258 | * is being evaluated. This result comes from a call to |
| 259 | * msql_query. |
| 260 | * @param int $field_offset The numerical field offset. The |
| 261 | * field_offset starts at 1. |
| 262 | * @return int The name of the table on success. |
| 263 | * @throws MsqlException |
| 264 | * |
| 265 | */ |
| 266 | function msql_field_table($result, int $field_offset): int |
| 267 | { |
| 268 | error_clear_last(); |
| 269 | $result = \ProfilePressVendor\msql_field_table($result, $field_offset); |
| 270 | if ($result === \false) { |
| 271 | throw MsqlException::createFromPhpError(); |
| 272 | } |
| 273 | return $result; |
| 274 | } |
| 275 | /** |
| 276 | * msql_field_type gets the type of the specified field |
| 277 | * index. |
| 278 | * |
| 279 | * @param resource $result The result resource that |
| 280 | * is being evaluated. This result comes from a call to |
| 281 | * msql_query. |
| 282 | * @param int $field_offset The numerical field offset. The |
| 283 | * field_offset starts at 1. |
| 284 | * @return string The type of the field. One of int, |
| 285 | * char, real, ident, |
| 286 | * null or unknown. This functions will |
| 287 | * return FALSE on failure. |
| 288 | * @throws MsqlException |
| 289 | * |
| 290 | */ |
| 291 | function msql_field_type($result, int $field_offset): string |
| 292 | { |
| 293 | error_clear_last(); |
| 294 | $result = \ProfilePressVendor\msql_field_type($result, $field_offset); |
| 295 | if ($result === \false) { |
| 296 | throw MsqlException::createFromPhpError(); |
| 297 | } |
| 298 | return $result; |
| 299 | } |
| 300 | /** |
| 301 | * msql_free_result frees the memory associated |
| 302 | * with query_identifier. When PHP completes a |
| 303 | * request, this memory is freed automatically, so you only need to |
| 304 | * call this function when you want to make sure you don't use too |
| 305 | * much memory while the script is running. |
| 306 | * |
| 307 | * @param resource $result The result resource that |
| 308 | * is being evaluated. This result comes from a call to |
| 309 | * msql_query. |
| 310 | * @throws MsqlException |
| 311 | * |
| 312 | */ |
| 313 | function msql_free_result($result): void |
| 314 | { |
| 315 | error_clear_last(); |
| 316 | $result = \ProfilePressVendor\msql_free_result($result); |
| 317 | if ($result === \false) { |
| 318 | throw MsqlException::createFromPhpError(); |
| 319 | } |
| 320 | } |
| 321 | /** |
| 322 | * msql_pconnect acts very much like |
| 323 | * msql_connect with two major differences. |
| 324 | * |
| 325 | * First, when connecting, the function would first try to find a |
| 326 | * (persistent) link that's already open with the same host. |
| 327 | * If one is found, an identifier for it will be returned instead of opening |
| 328 | * a new connection. |
| 329 | * |
| 330 | * Second, the connection to the SQL server will not be closed when the |
| 331 | * execution of the script ends. Instead, the link will remain open for |
| 332 | * future use (msql_close will not close links |
| 333 | * established by this function). |
| 334 | * |
| 335 | * @param string $hostname The hostname can also include a port number. e.g. |
| 336 | * hostname,port. |
| 337 | * |
| 338 | * If not specified, the connection is established by the means of a Unix |
| 339 | * domain socket, being more efficient than a localhost TCP socket |
| 340 | * connection. |
| 341 | * @return resource Returns a positive mSQL link identifier on success. |
| 342 | * @throws MsqlException |
| 343 | * |
| 344 | */ |
| 345 | function msql_pconnect(string $hostname = null) |
| 346 | { |
| 347 | error_clear_last(); |
| 348 | if ($hostname !== null) { |
| 349 | $result = \ProfilePressVendor\msql_pconnect($hostname); |
| 350 | } else { |
| 351 | $result = \ProfilePressVendor\msql_pconnect(); |
| 352 | } |
| 353 | if ($result === \false) { |
| 354 | throw MsqlException::createFromPhpError(); |
| 355 | } |
| 356 | return $result; |
| 357 | } |
| 358 | /** |
| 359 | * msql_query sends a query to the currently active |
| 360 | * database on the server that's associated with the specified link |
| 361 | * identifier. |
| 362 | * |
| 363 | * @param string $query The SQL query. |
| 364 | * @param resource|null $link_identifier The mSQL connection. |
| 365 | * If not specified, the last link opened by msql_connect |
| 366 | * is assumed. If no such link is found, the function will try to establish a |
| 367 | * link as if msql_connect was called, and use it. |
| 368 | * @return resource Returns a positive mSQL query identifier on success. |
| 369 | * @throws MsqlException |
| 370 | * |
| 371 | */ |
| 372 | function msql_query(string $query, $link_identifier = null) |
| 373 | { |
| 374 | error_clear_last(); |
| 375 | if ($link_identifier !== null) { |
| 376 | $result = \ProfilePressVendor\msql_query($query, $link_identifier); |
| 377 | } else { |
| 378 | $result = \ProfilePressVendor\msql_query($query); |
| 379 | } |
| 380 | if ($result === \false) { |
| 381 | throw MsqlException::createFromPhpError(); |
| 382 | } |
| 383 | return $result; |
| 384 | } |
| 385 | /** |
| 386 | * msql_select_db sets the current active database on |
| 387 | * the server that's associated with the specified |
| 388 | * link_identifier. |
| 389 | * |
| 390 | * Subsequent calls to msql_query will be made on the |
| 391 | * active database. |
| 392 | * |
| 393 | * @param string $database_name The database name. |
| 394 | * @param resource|null $link_identifier The mSQL connection. |
| 395 | * If not specified, the last link opened by msql_connect |
| 396 | * is assumed. If no such link is found, the function will try to establish a |
| 397 | * link as if msql_connect was called, and use it. |
| 398 | * @throws MsqlException |
| 399 | * |
| 400 | */ |
| 401 | function msql_select_db(string $database_name, $link_identifier = null): void |
| 402 | { |
| 403 | error_clear_last(); |
| 404 | if ($link_identifier !== null) { |
| 405 | $result = \ProfilePressVendor\msql_select_db($database_name, $link_identifier); |
| 406 | } else { |
| 407 | $result = \ProfilePressVendor\msql_select_db($database_name); |
| 408 | } |
| 409 | if ($result === \false) { |
| 410 | throw MsqlException::createFromPhpError(); |
| 411 | } |
| 412 | } |
| 413 |