#native_company# #native_desc#
#native_cta#

PHPLib and Multiple Databases Page 2

By Peter Moulding
on November 7, 2000

Including PHPLIB

PHPLIB accesses SQL databases through a class named DB_Sql. You include the
version for your database in your code. I use the MySQL version in this
example.
To get DB_Sql in to your code, install the PHPLIB files in their own
directory. Then, find your cgi-bin directory and create the phplib directory next
to the cgi-bin directory. Next, copy all the PHPLIB .inc files in to the phplib
directory. Finally, put the phplib directory in to the php.inc file in the line
starting with include_path =.
The include_path is where PHP grabs files named in include() or require().
On my NT workstation, the include path is…

 include_path = ".;i:/project52/includes;i:/project52/phplib";
On the Linux production machine, it is…

 include_path = ".;/home/httpd/includes;/home/httpd/phplib";
 
At the top of each PHP page is…

<?php

require(common.php3);

?>



common.php3 is in the includes directory and contains all the data and
functions common to every page. In common.php3, are…

<?php

require(db_mysql.inc);

require(
ct_sql.inc);

require(
session.inc);

require(
auth.inc);

require(
perm.inc);

require(
user.inc);

require(
page.inc);

?>



Read the PHPLIB documentation at http://phplib.netuse.de and the fine
articles at https://phpbuilder.com to find out which includes you need.
Db_mysql.inc contains the DB_Sql class definition. If you want to use
PostGreSQL instead of MySQL, include db_pgsql.inc instead of db_mysql.inc.
There are 10 .incs covering MS SQL, Oracle, Sybase and others.
*Note that for this example, require() and include() are exactly the
same. Require() and include() do work differently and have different
results when used in the middle of your code or in if() statements.