PHP  
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
search for in the  
<maxdb_connect_errormaxdb_data_seek>
Last updated: Mon, 16 Jul 2012

maxdb_connect

(PECL)

maxdb_connect

(no version information, might be only in CVS)

maxdb() -- Open a new connection to the MaxDB server

Description

Procedural style

resource maxdb_connect ( [string host [, string username [, string passwd [, string dbname [, int port [, string socket]]]]]] )

Object oriented style (constructor):

class maxdb {

__construct ( [string host [, string username [, string passwd [, string dbname [, int port [, string socket]]]]]] )

}

The maxdb_connect() function attempts to open a connection to the MaxDB Server running on host which can be either a host name or an IP address. Passing the string "localhost" to this parameter, the local host is assumed. If successful, the maxdb_connect() will return an resource representing the connection to the database, or FALSE on failure.

The username and password parameters specify the username and password under which to connect to the MaxDB server. If the password is not provided (the NULL value is passed), the MaxDB server will attempt to authenticate the user against the maxdb.default_pw in php.ini.

The dbname parameter if provided will specify the default database to be used when performing queries. If not provied, the entry maxdb.default_db in php.ini is used.

The port and socket parameters are ignored for the MaxDB server.

Return values

Returns a resource which represents the connection to a MaxDB Server or FALSE if the connection failed.

Example

例子 1. Object oriented style

<?php
$maxdb
= new maxdb("localhost", "MONA", "RED", "DEMODB");

/* check connection */
if (maxdb_connect_errno()) {
  
printf("Connect failed: %s\n", maxdb_connect_error());
   exit();
}

printf("Host information: %s\n", $maxdb->host_info);

/* close connection */
$maxdb->close();
?>

例子 2. Procedural style

<?php
$link
= maxdb_connect("localhost", "MONA", "RED", "DEMODB");

/* check connection */
if (!$link) {
  
printf("Connect failed: %s\n", maxdb_connect_error());
   exit();
}

printf("Host information: %s\n", maxdb_get_host_info($link));

/* close connection */
maxdb_close($link);
?>

The above examples would produce the following output:

Host information: localhost



<maxdb_connect_errormaxdb_data_seek>
 Last updated: Mon, 16 Jul 2012
 
Copyright © 2001-2005 The PHP Group
All rights reserved.
This unofficial mirror is operated at: http://manual.phpv.net/
Last updated: Thu Jul 7 19:13:47 2005 CST