PHP kézikönyv
Előző |  | Következő

# LXIV. MaxDB PHP Extension

# Bevezetés

The MaxDB PHP extension allows you to access the functionality provided by MaxDB 7.5.0 and above. More information about the MaxDB Database server can be found at http://www.mysql.com/products/maxdb/.

Documentation for MaxDB can be found at http://dev.mysql.com/doc/maxdb/.

# Követelmények

In order to have these functions available, you must compile PHP with MaxDB support.Additionally, you must have the MaxDB SQLDBC runtime library available to access the MaxDB server.

Documentation for MaxDB SQLDBC can be found at http://dev.mysql.com/doc/maxdb/.

Download the MaxDB SQLDBC package from http://dev.mysql.com/downloads/maxdb/clients.html.

# Telepítés

By using the --with-maxdb[=DIR] configuration option you enable PHP to access MaxDB databases. [DIR] points to the directory that contains the installed MaxDB SQLDBC package.

Windows users will need to enable `php_maxdb.dll` inside of `php.ini`.

# Futásidejű beállítások

Az alábbi függvények viselkedése befolyásolható a `php.ini` segítségével.

Táblázat 1. MaxDB Configuration Options

Name | Default | Changeable
--- | --- | ---
maxdb.default_host | NULL | PHP_INI_ALL
maxdb.default_db | NULL | PHP_INI_ALL
maxdb.default_user | NULL | PHP_INI_ALL
maxdb.default_password | NULL | PHP_INI_ALL
maxdb.long_readlen | NULL | PHP_INI_ALL

További részletekért és a PHP_INI_* konstnsok definícióiért lásd az ini_set() dokumentációt.

A témába vágó konfigurációs direktívák rövid leírása

maxdb.default_host string

  The default server host to use when connecting to the database server if no other host is specified.

maxdb.default_db string

  The default server database to use when connecting if no other database is specified.

maxdb.default_user string

  The default user name to use when connecting to the database server if no other name is specified.

maxdb.default_password string

  The default password to use when connecting to the database server if no other password is specified.

maxdb.long_readlen integer

  The default maximum length of bytes that is transferred to the client if long data is retrieved from the MaxDB database server.

# Előre definiált állandók

Az itt listázott állandókat ez a kiterjesztés definiálja, és csak akkor elérhetőek, ha az adott kiterjesztés be van fordítva a PHP-be, vagy dinamikusan betöltött.

The following constants to use with maxdb_options() are defined. For further description of these constants see http://dev.mysql.com/doc/maxdb/.

Táblázat 2. MaxDB PHP client constants

Constant | Description
--- | ---
MAXDB_COMPNAME | The component name used to initialise the SQLDBC runtime environment.
MAXDB_APPLICATION | The application to be connected to the database.
MAXDB_APPVERSION | The version of the application.
MAXDB_SQLMODE | The SQL mode.
MAXDB_UNICODE | TRUE, if the connection is an unicode (UCS2) client or FALSE, if not.
MAXDB_TIMEOUT | The maximum allowed time of inactivity after which the connection to the database is closed by the system.
MAXDB_ISOLATIONLEVEL | Specifies whether and how shared locks and exclusive locks are implicitly requested or released.
MAXDB_PACKETCOUNT | The number of different request packets used for the connection.
MAXDB_STATEMENTCACHESIZE | The number of prepared statements to be cached for the connection for re-use.
MAXDB_CURSORPREFIX | The prefix to use for result tables that are automatically named.

The function maxdb_fetch_array() uses a constant for the different types of result arrays. The following constants are defined:

Táblázat 3. MaxDB fetch constants

Constant | Description
--- | ---
MAXDB_ASSOC | Columns are returned into the array having the fieldname as the array index.
MAXDB_BOTH | Columns are returned into the array having both a numerical index and the fieldname as the array index.
MAXDB_NUM | Columns are returned into the array having a numerical index to the fields. This index starts with 0, the first field in the result.

# Példák

All examples in the MaxDB PHP documentation use the HOTELDB demo database from MaxDB. More about this database can be found at http://dev.mysql.com/doc/maxdb/en/98/11b83fa6b33c17e10000000a114084/frameset.htm.

This simple example shows how to connect, execute a query, print resulting rows and disconnect from a MaxDB database.

Példa 1. MaxDB extension overview example

`<?php
/* Connecting, selecting database */
$link = maxdb_connect("maxdb_host", "maxdb_user", "maxdb_password")
or die("Could not connect : " . maxdb_connect_error());
echo "Connected successfully";
maxdb_select_db("my_database") or die("Could not select database");
/* Performing SQL query */
$query = "SELECT * FROM my_table";
$result = maxdb_query($link, $query) or die("Query failed : " . maxdb_error());
/* Printing results in HTML */
echo "<table>\n";
while ($line = maxdb_fetch_array($result, MAXDB_ASSOC)) {
echo "\t<tr>\n";
foreach ($line as $col_value) {
echo "\t\t<td>$col_value</td>\n";
}
echo "\t</tr>\n";
}
echo "</table>\n";
/* Free resultset */
maxdb_free_result($result);
/* Closing connection */
maxdb_close($link);
?>`

Előző | Tartalom | Következő
tanh | Fel | maxdb_affected_rows