{"id":1263,"date":"2018-01-19T19:22:37","date_gmt":"2018-01-19T19:22:37","guid":{"rendered":"http:\/\/goofy-trucks.flywheelsites.com\/phplib-and-multiple-databases-page-2\/"},"modified":"2018-01-19T19:24:39","modified_gmt":"2018-01-19T19:24:39","slug":"phplib-and-multiple-databases-page-2","status":"publish","type":"post","link":"https:\/\/phpbuilder.com\/phplib-and-multiple-databases-page-2\/","title":{"rendered":"PHPLib and Multiple Databases Page 2"},"content":{"rendered":"<div class=\"phpbuilder-content\">\n<div class=\"phpbuilder-meta\">\n<div class=\"\">By Peter Moulding<\/div>\n<div class=\"\">on November 7, 2000<\/div>\n<\/p><\/div>\n<div id=\"overflow-content\">\n<h2> Including PHPLIB<\/h2>\n<div class=\"articlePara\">\n PHPLIB accesses SQL databases through a class named DB_Sql. You include the<br \/>\n version for your database in your code. I use the MySQL version in this<br \/>\n example.<\/div>\n<div class=\"articlePara\">\n To get DB_Sql in to your code, install the PHPLIB files in their own<br \/>\n directory. Then, find your cgi-bin directory and create the phplib directory next<br \/>\n to the cgi-bin directory. Next, copy all the PHPLIB .inc files in to the phplib<br \/>\n directory. Finally, put the phplib directory in to the php.inc file in the line<br \/>\n starting with include_path =.<\/div>\n<div class=\"articlePara\">\n The include_path is where PHP grabs files named in include() or require().<br \/>\n On my NT workstation, the include path is&#8230;<\/p>\n<pre>\n include_path = \".;i:\/project52\/includes;i:\/project52\/phplib\";\n<\/pre>\n<\/div>\n<div class=\"articlePara\">\n On the Linux production machine, it is&#8230;<\/p>\n<pre>\n include_path = \".;\/home\/httpd\/includes;\/home\/httpd\/phplib\";\n <\/pre>\n<\/div>\n<div class=\"articlePara\">\n At the top of each PHP page is&#8230;<\/div>\n<div class=\"articlePhpEx\">\n<font face=\"courier\"><code><span style=\"color: #000000\"><\/p>\n<p><span style=\"color: #0000BB\">&lt;?php<\/p>\n<p><\/span><span style=\"color: #007700\">require(<\/span><span style=\"color: #0000BB\">common<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">php3<\/span><span style=\"color: #007700\">);<\/p>\n<p><\/span><span style=\"color: #0000BB\">?&gt;<br \/>\n<br \/><\/span><br \/>\n<\/span><br \/>\n<\/code><\/font><\/div>\n<div class=\"articlePara\">\n common.php3 is in the includes directory and contains all the data and<br \/>\n functions common to every page. In common.php3, are&#8230;<\/div>\n<div class=\"articlePhpEx\">\n<font face=\"courier\"><code><span style=\"color: #000000\"><\/p>\n<p><span style=\"color: #0000BB\">&lt;?php<\/p>\n<p><\/span><span style=\"color: #007700\">require(<\/span><span style=\"color: #0000BB\">db_mysql<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">inc<\/span><span style=\"color: #007700\">);<br \/>\n<br \/>require(<\/span><span style=\"color: #0000BB\">ct_sql<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">inc<\/span><span style=\"color: #007700\">);<br \/>\n<br \/>require(<\/span><span style=\"color: #0000BB\">session<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">inc<\/span><span style=\"color: #007700\">);<br \/>\n<br \/>require(<\/span><span style=\"color: #0000BB\">auth<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">inc<\/span><span style=\"color: #007700\">);<br \/>\n<br \/>require(<\/span><span style=\"color: #0000BB\">perm<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">inc<\/span><span style=\"color: #007700\">);<br \/>\n<br \/>require(<\/span><span style=\"color: #0000BB\">user<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">inc<\/span><span style=\"color: #007700\">);<br \/>\n<br \/>require(<\/span><span style=\"color: #0000BB\">page<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">inc<\/span><span style=\"color: #007700\">);<\/p>\n<p><\/span><span style=\"color: #0000BB\">?&gt;<br \/>\n<br \/><\/span><br \/>\n<\/span><br \/>\n<\/code><\/font><\/div>\n<div class=\"articlePara\">\n Read the PHPLIB documentation at http:\/\/phplib.netuse.de and the fine<br \/>\n articles at https:\/\/phpbuilder.com to find out which includes you need.<br \/>\n Db_mysql.inc contains the DB_Sql class definition. If you want to use<br \/>\n PostGreSQL instead of MySQL, include db_pgsql.inc instead of db_mysql.inc.<br \/>\n There are 10 .incs covering MS SQL, Oracle, Sybase and others.<\/div>\n<div class=\"articlePara\">\n *Note that for this example, require() and include() are exactly the<br \/>\n same. Require() and include() do work differently and have different<br \/>\n results when used in the middle of your code or in if() statements.<\/div>\n<\/div>\n<p><\/p>\n<div style=\"float: left; padding:15px; color:#17AAF3\">\n<div style=\"float:left; padding:2px;\"><a class=\"paginationPageLink\" href=\"peter20001107.html\">\u00ab Previous Page<\/a><\/div>\n<div style=\"float:left; padding:2px 4px 2px 4px;\"><a class=\"pageNumber\" href=\"peter20001107.html\">1<\/a> <\/div>\n<div style=\"float:left; font-size:16px; color:#FF7A22; padding:2px 2px 2px 2px; \">| <\/div>\n<div style=\"background-color:#B6E5FC; font-size:16px; margin-top:1px; padding:1px 4px 1px 4px; color:#000; font-style:bold; float:left;\">2<\/div>\n<div style=\"float:left; font-size:16px; color:#FF7A22; padding:2px 2px 2px 2px; \">| <\/div>\n<div style=\"float:left; padding:2px 4px 2px 4px;\"><a class=\"pageNumber\" href=\"peter200011079ba9.html?page=3\">3<\/a> <\/div>\n<div style=\"float:left; font-size:16px; color:#FF7A22; padding:2px 2px 2px 2px; \">| <\/div>\n<div style=\"float:left; padding:2px 4px 2px 4px;\"><a class=\"pageNumber\" href=\"peter20001107fdb0.html?page=4\">4<\/a> <\/div>\n<div style=\"float:left; font-size:16px; color:#FF7A22; padding:2px 2px 2px 2px; \">| <\/div>\n<div style=\"float:left; padding:2px 4px 2px 4px;\"><a class=\"pageNumber\" href=\"peter20001107af4d.html?page=5\">5<\/a> <\/div>\n<div style=\"float:left; font-size:16px; color:#FF7A22; padding:2px 2px 2px 2px; \">| <\/div>\n<div style=\"float:left; padding:2px 4px 2px 4px;\"><a class=\"pageNumber\" href=\"peter20001107c575.html?page=6\">6<\/a> <\/div>\n<div style=\"float:left; padding:2px;\"><a class=\"paginationPageLink\" href=\"peter200011079ba9.html?page=3\">Next Page \u00bb<\/a><\/div>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>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&#8230; <a href=\"https:\/\/phpbuilder.com\/phplib-and-multiple-databases-page-2\/\" class=\"readmore\"><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-1263","post","type-post","status-publish","format-standard","hentry","category-tutorials"],"_links":{"self":[{"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/posts\/1263","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/comments?post=1263"}],"version-history":[{"count":1,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/posts\/1263\/revisions"}],"predecessor-version":[{"id":3156,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/posts\/1263\/revisions\/3156"}],"wp:attachment":[{"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/media?parent=1263"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/categories?post=1263"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/tags?post=1263"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}