resource mysql_connect ( [string server [, string username [, string password 
[, bool new_link [, int client_flags]]]]])
Another way to connect to a MySQL server is to use the 
mysql_pconnect()
function, which acts very much like 
mysql_connect()
 with two major differences: 
When connecting the first time, the function would try to find a (persistent) link 
that is already open with the same host, username and password. If one is 
found, an identifier for it will be returned instead of opening a new connection. 
The connection to the MySQL server will not be closed when the execution of 
the script ends. Instead, the link will remain open for future use.
The
 server
 variable in the 
mysql_connect()
 function contains the hostname or 
the IP address of the server that provides the MySQL database.
Choosing the MySQL database is done by the mysql_select_db() function:
bool mysql_select_db ( string database_name [, resource link_identifier])
The connection part of our sample application using MySQL database is shown 
in Example 7 22.
Example 7 22   Connecting a MySQL database
$db_host   = "localhost";
$db_user   = "itsosj";
$db_pass   = "itsosj";
$datab     = "itsodb";
$db = mysql_connect($db_host,$db_user,$db_pass) 
or die("Could not connect ".
mysql_error());
mysql_select_db($datab,$db) or die(mysql_error());
When connecting a DB2 database with ODBC, the connection is done in a single 
ODBC command (
odbc_connect()
).
resource odbc_connect ( string dsn, string user, string password [, int 
cursor_type])
Note:
 As we use the IBM DB2 native driver, the DSN is the database name 
which is registered in the DB2 catalog. Therefore, no server address has to be 
declared in the connect statement.
The migrated connection part of the sample application is shown in 
Example 7 23. In our connection script snippet, the statement after connection 
statement sets the current schema, which will be used when querying the 
 Chapter 7. Application porting 
179






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

san diego web hosting

 

Our partners: PHP: Hypertext Preprocessor Cheap Web Hosting JSP Web Hosting Ontario Web Hosting  Jsp Web Hosting

Cheapest Web Hosting Java Hosting Cheapest Hosting

Visionwebhosting.net Business web hosting division of Vision Web Hosting Inc.. All rights reserved