php ADOLoadCode类(方法)实例源码

下面列出了php ADOLoadCode 类(方法)源码代码实例,从而了解它的用法。

作者:radicaldesign    项目:gt   
function getDb()
 {
     static $dbcon;
     if ($dbcon) {
         return $dbcon;
     }
     ADOLoadCode('mysql');
     $dbcon =& ADONewConnection('mysql');
     if (!$dbcon->Connect(DB_HOST, DB_USER, DB_PASS, DB_NAME)) {
         die('Connection to database ' . DB_NAME . ' was refused.  Please check database_config file.');
     }
     return $dbcon;
 }

作者:advancingdesig    项目:ADOd   
/**
 * Instantiate a new Connection class for a specific database driver.
 *
 * @param [db]  is the database Connection object to create. If undefined,
 *	use the last database driver that was loaded by ADOLoadCode().
 *
 * @return the freshly created instance of the Connection class.
 */
function ADONewConnection($db = '')
{
    global $ADODB_NEWCONNECTION, $ADODB_LASTDB;
    if (!defined('ADODB_ASSOC_CASE')) {
        define('ADODB_ASSOC_CASE', ADODB_ASSOC_CASE_NATIVE);
    }
    $errorfn = defined('ADODB_ERROR_HANDLER') ? ADODB_ERROR_HANDLER : false;
    if (($at = strpos($db, '://')) !== FALSE) {
        $origdsn = $db;
        $fakedsn = 'fake' . substr($origdsn, $at);
        if (($at2 = strpos($origdsn, '@/')) !== FALSE) {
            // special handling of oracle, which might not have host
            $fakedsn = str_replace('@/', '@adodb-fakehost/', $fakedsn);
        }
        if (strpos($origdsn, 'sqlite') !== FALSE && stripos($origdsn, '%2F') === FALSE) {
            // special handling for SQLite, it only might have the path to the database file.
            // If you try to connect to a SQLite database using a dsn
            // like 'sqlite:///path/to/database', the 'parse_url' php function
            // will throw you an exception with a message such as "unable to parse url"
            list($scheme, $path) = explode('://', $origdsn);
            $dsna['scheme'] = $scheme;
            if ($qmark = strpos($path, '?')) {
                $dsn['query'] = substr($path, $qmark + 1);
                $path = substr($path, 0, $qmark);
            }
            $dsna['path'] = '/' . urlencode($path);
        } else {
            $dsna = @parse_url($fakedsn);
        }
        if (!$dsna) {
            return false;
        }
        $dsna['scheme'] = substr($origdsn, 0, $at);
        if ($at2 !== FALSE) {
            $dsna['host'] = '';
        }
        if (strncmp($origdsn, 'pdo', 3) == 0) {
            $sch = explode('_', $dsna['scheme']);
            if (sizeof($sch) > 1) {
                $dsna['host'] = isset($dsna['host']) ? rawurldecode($dsna['host']) : '';
                if ($sch[1] == 'sqlite') {
                    $dsna['host'] = rawurlencode($sch[1] . ':' . rawurldecode($dsna['host']));
                } else {
                    $dsna['host'] = rawurlencode($sch[1] . ':host=' . rawurldecode($dsna['host']));
                }
                $dsna['scheme'] = 'pdo';
            }
        }
        $db = @$dsna['scheme'];
        if (!$db) {
            return false;
        }
        $dsna['host'] = isset($dsna['host']) ? rawurldecode($dsna['host']) : '';
        $dsna['user'] = isset($dsna['user']) ? rawurldecode($dsna['user']) : '';
        $dsna['pass'] = isset($dsna['pass']) ? rawurldecode($dsna['pass']) : '';
        $dsna['path'] = isset($dsna['path']) ? rawurldecode(substr($dsna['path'], 1)) : '';
        # strip off initial /
        if (isset($dsna['query'])) {
            $opt1 = explode('&', $dsna['query']);
            foreach ($opt1 as $k => $v) {
                $arr = explode('=', $v);
                $opt[$arr[0]] = isset($arr[1]) ? rawurldecode($arr[1]) : 1;
            }
        } else {
            $opt = array();
        }
    }
    /*
     *  phptype: Database backend used in PHP (mysql, odbc etc.)
     *  dbsyntax: Database used with regards to SQL syntax etc.
     *  protocol: Communication protocol to use (tcp, unix etc.)
     *  hostspec: Host specification (hostname[:port])
     *  database: Database to use on the DBMS server
     *  username: User name for login
     *  password: Password for login
     */
    if (!empty($ADODB_NEWCONNECTION)) {
        $obj = $ADODB_NEWCONNECTION($db);
    }
    if (empty($obj)) {
        if (!isset($ADODB_LASTDB)) {
            $ADODB_LASTDB = '';
        }
        if (empty($db)) {
            $db = $ADODB_LASTDB;
        }
        if ($db != $ADODB_LASTDB) {
            $db = ADOLoadCode($db);
        }
        if (!$db) {
            if (isset($origdsn)) {
                $db = $origdsn;
//.........这里部分代码省略.........

作者:sraj    项目:EthicsPublicHtmlPro   
}
}
ADOLoadCode("ado_mssql");
if (!empty($testmssql) && !empty($testado)) {
    // ADO ACCESS MSSQL -- thru ODBC -- DSN-less
    $db =& ADONewConnection("ado_mssql");
    $db->debug = 1;
    print "<h1>Connecting DSN-less {$db->databaseType}...</h1>";
    $myDSN = "PROVIDER=MSDASQL;DRIVER={SQL Server};" . "SERVER=JAGUAR\\VSDOTNET;DATABASE=NorthWind;UID=adodb;PWD=natsoft;Trusted_Connection=No";
    if (@$db->PConnect($myDSN, "", "", "")) {
        testdb($db, "create table ADOXYZ (id int, firstname char(24) null, lastname char(24) null,created datetime null)");
    } else {
        print "ERROR: MSSQL test 2 requires MS SQL 7";
    }
}
ADOLoadCode("mssqlpo");
if (!empty($testmssql)) {
    // MS SQL Server -- the extension is buggy -- probably better to use ODBC
    $db = ADONewConnection();
    $db->debug = 1;
    print "<h1>Connecting {$db->databaseType}...</h1>";
    $db->PConnect('JAGUAR\\vsdotnet', 'adodb', 'natsoft', 'northwind');
    if (true or @$db->PConnect("mangrove", "sa", "natsoft", "ai")) {
        AutoDetect_MSSQL_Date_Order($db);
        //	$db->Execute('drop table adoxyz');
        testdb($db, "create table ADOXYZ (id int, firstname char(24) null, lastname char(24) null,created datetime null)");
    } else {
        print "ERROR: MSSQL test 2 requires a MS SQL 7 on a server='192.168.0.1', userid='sa', password='natsoft', database='ai'" . '<BR>' . $db->ErrorMsg();
    }
}
if (!empty($testmssql) && !empty($testado)) {

作者:parxomchi    项目:Agr   
/**
  * Instantiate a new Connection class for a specific database driver.
  *
  * @param [db]  is the database Connection object to create. If undefined,
  * 	use the last database driver that was loaded by ADOLoadCode().
  *
  * @return the freshly created instance of the Connection class.
  */
 function &ADONewConnection($db = '')
 {
     global $ADODB_Database;
     $rez = true;
     if ($db) {
         if ($ADODB_Database != $db) {
             ADOLoadCode($db);
         }
     } else {
         if (!empty($ADODB_Database)) {
             ADOLoadCode($ADODB_Database);
         } else {
             $rez = false;
         }
     }
     $errorfn = defined('ADODB_ERROR_HANDLER') ? ADODB_ERROR_HANDLER : false;
     if (!$rez) {
         if ($errorfn) {
             // raise an error
             $errorfn('ADONewConnection', 'ADONewConnection', -998, "could not load the database driver for '{$db}", $dbtype);
         } else {
             ADOConnection::outp("<p>ADONewConnection: Unable to load database driver '{$db}'</p>", false);
         }
         return false;
     }
     $cls = 'ADODB_' . $ADODB_Database;
     $obj = new $cls();
     if ($errorfn) {
         $obj->raiseErrorFn = $errorfn;
     }
     return $obj;
 }

作者:dalinhuan    项目:hlwvincen   
function ADOLoadCode2($d)
{
    ADOLoadCode($d);
    $c = ADONewConnection($d);
    echo "Loaded {$d} ", $c ? 'ok' : 'extension not installed', "<br>";
}

作者:BackupTheBerlio    项目:facturaphp-sv   
<body>
<?php 
/*
 V4.22 15 Apr 2004  (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
 Released under both BSD license and Lesser GPL library license. 
 Whenever there is any discrepancy between the two licenses, 
 the BSD license will take precedence.
 Set tabs to 8.
*/
#
# test connecting to 2 MySQL databases simultaneously and ensure that each connection
# is independant.
#
include "../tohtml.inc.php";
include "../adodb.inc.php";
ADOLoadCode('mysql');
$c1 = ADONewConnection('oci8');
if (!$c1->PConnect('', 'scott', 'tiger')) {
    die("Cannot connect to server");
}
$c1->debug = 1;
$rs = $c1->Execute('select rownum, p1.firstname,p2.lastname,p2.firstname,p1.lastname from adoxyz p1, adoxyz p2');
print "Records=" . $rs->RecordCount() . "<br><pre>";
//$rs->_array = false;
//$rs->connection = false;
//print_r($rs);
rs2html($rs);
?>


</body>

作者:radicaldesign    项目:am   
die("Incomplete database configuration. Please contact your system administrator.");
    }
} else {
    die("Couldn't find a local site configuration file. Please contact your system administrator.");
}
if (!isset($ADODB_CACHE_DIR) || !is_dir($ADODB_CACHE_DIR) || !is_writable($ADODB_CACHE_DIR)) {
    $ADODB_CACHE_DIR = AMP_urlFlip(AMP_LOCAL_PATH . '/cache');
}
if (!defined('AMP_BASE_PATH')) {
    define('AMP_BASE_PATH', $_SERVER['DOCUMENT_ROOT']);
}
if (!defined('AMP_BASE_INCLUDE_PATH')) {
    define('AMP_BASE_INCLUDE_PATH', $_SERVER['DOCUMENT_ROOT'] . '/include/');
}
// turn on APD debugger when set by config file
if (defined('AMP_DEBUG_MODE_APD') && AMP_DEBUG_MODE_APD && function_exists('apd_set_pprof_trace')) {
    apd_set_pprof_trace();
}
// Connect to the database.
if (!defined('AMP_DB_TYPE')) {
    define('AMP_DB_TYPE', 'mysql');
}
ADOLoadCode(AMP_DB_TYPE);
$dbcon = ADONewConnection(AMP_DB_TYPE);
if (!$dbcon->Connect(AMP_DB_HOST, AMP_DB_USER, AMP_DB_PASS, AMP_DB_NAME)) {
    die('Connection to database ' . AMP_DB_NAME . ' was refused.  Please check your site configuration file.');
}
require_once 'AMP/Registry.php';
//add the dbcon to the Registry
$registry = AMP_Registry::instance();
$registry->setDbcon($dbcon);

作者:qoir    项目:porta   
/**
  * Instantiate a new Connection class for a specific database driver.
  *
  * @param [db]  is the database Connection object to create. If undefined,
  * 	use the last database driver that was loaded by ADOLoadCode().
  *
  * @return the freshly created instance of the Connection class.
  */
 function &ADONewConnection($db = '')
 {
     global $ADODB_Database;
     if ($db) {
         if ($ADODB_Database != $db) {
             ADOLoadCode($db);
         }
     } else {
         if (!empty($ADODB_Database)) {
             ADOLoadCode($ADODB_Database);
         } else {
             print "<p>ADONewConnection: No database driver defined</p>";
         }
     }
     $cls = 'ADODB_' . $ADODB_Database;
     $obj = new $cls();
     if (defined('ADODB_ERROR_HANDLER')) {
         $obj->raiseErrorFn = ADODB_ERROR_HANDLER;
     }
     return $obj;
 }

作者:BackupTheBerlio    项目:facturaphp-sv   
/**
  * Instantiate a new Connection class for a specific database driver.
  *
  * @param [db]  is the database Connection object to create. If undefined,
  * 	use the last database driver that was loaded by ADOLoadCode().
  *
  * @return the freshly created instance of the Connection class.
  */
 function &ADONewConnection($db = '')
 {
     global $ADODB_NEWCONNECTION, $ADODB_LASTDB;
     if (!defined('ADODB_ASSOC_CASE')) {
         define('ADODB_ASSOC_CASE', 2);
     }
     $errorfn = defined('ADODB_ERROR_HANDLER') ? ADODB_ERROR_HANDLER : false;
     if (!empty($ADODB_NEWCONNECTION)) {
         $obj = $ADODB_NEWCONNECTION($db);
         if ($obj) {
             if ($errorfn) {
                 $obj->raiseErrorFn = $errorfn;
             }
             return $obj;
         }
     }
     if (!isset($ADODB_LASTDB)) {
         $ADODB_LASTDB = '';
     }
     if (empty($db)) {
         $db = $ADODB_LASTDB;
     }
     if ($db != $ADODB_LASTDB) {
         $db = ADOLoadCode($db);
     }
     if (!$db) {
         if ($errorfn) {
             // raise an error
             $ignore = false;
             $errorfn('ADONewConnection', 'ADONewConnection', -998, "could not load the database driver for '{$db}", $db, false, $ignore);
         } else {
             ADOConnection::outp("<p>ADONewConnection: Unable to load database driver '{$db}'</p>", false);
         }
         return false;
     }
     $cls = 'ADODB_' . $db;
     if (!class_exists($cls)) {
         adodb_backtrace();
         return false;
     }
     $obj =& new $cls();
     if ($errorfn) {
         $obj->raiseErrorFn = $errorfn;
     }
     return $obj;
 }

作者:qoir    项目:porta   
print "ERROR: MSSQL test 1 requires a MS SQL 7 server setup with DSN='lensengine', userid='sa', password=''";
    }
}
ADOLoadCode("ado_mssql");
if (!empty($testmssql) && !empty($testado)) {
    // ADO ACCESS MSSQL -- thru ODBC -- DSN-less
    $db =& ADONewConnection("ado_mssql");
    print "<h1>Connecting DSN-less {$db->databaseType}...</h1>";
    $myDSN = "PROVIDER=MSDASQL;DRIVER={SQL Server};" . "SERVER=mangrove;DATABASE=ai;UID=sa;PWD=;";
    if (@$db->PConnect($myDSN, "", "", "")) {
        testdb($db, "create table ADOXYZ (id int, firstname char(24), lastname char(24),created datetime)");
    } else {
        print "ERROR: MSSQL test 2 requires a MS SQL 7 on a server='mangrove', userid='sa', password='', database='ai'";
    }
}
ADOLoadCode("mssql");
if (!empty($testmssql)) {
    // MS SQL Server -- the extension is buggy -- probably better to use ODBC
    $db = ADONewConnection();
    print "<h1>Connecting {$db->databaseType}...</h1>";
    if (@$db->PConnect("mangrove", "sa", "", "ai")) {
        testdb($db, "create table ADOXYZ (id int, firstname char(24), lastname char(24),created datetime)");
    } else {
        print "ERROR: MSSQL test 2 requires a MS SQL 7 on a server='192.168.0.1', userid='sa', password='', database='ai'" . '<BR>' . $db->ErrorMsg();
    }
}
if (!empty($testmssql) && !empty($testado)) {
    // ADO ACCESS MSSQL with OLEDB provider
    $db =& ADONewConnection("ado_mssql");
    print "<h1>Connecting DSN-less OLEDB Provider {$db->databaseType}...</h1>";
    $myDSN = "SERVER=mangrove;DATABASE=ai;";

作者:gambri    项目:ceramichesofi   
<?php

require_once "adodb.inc.php";
// Istanziazione AdoDB
$HOSTNAME = "localhost";
//INDIRIZZO;
$DATABASE = "mysql:ceramichesofia";
//DATABASE;
$DBTYPE = preg_replace("/:.*\$/", "", $DATABASE);
$DATABASE = preg_replace("/^.*?:/", "", $DATABASE);
$USERNAME = "gambric";
//UTENTE;
$PASSWORD = "gambric";
//PASSWORD;
$LOCALE = "It";
ADOLoadCode($DBTYPE);
$db_conn =& ADONewConnection($DBTYPE);
$db_conn->PConnect($HOSTNAME, $USERNAME, $PASSWORD, $DATABASE, $LOCALE);

作者:qoir    项目:porta   
* You might still get database connection errors because you
 * didn't configure PHPLENS_SESSION_* variables in 
 *           phplens/config/phplens.config.inc.php.
 */
$rt = array('FirstName', 'LastName', 'Num');
$r0 = array('John', 'Lim', '1');
$r1 = array('Harry', 'Zee', '2');
$r2 = array('Larry', 'Aaron', '3');
$r3 = array('Baddy', 'Lim', '4');
$r4 = array('John', 'Lee', '5');
$r5 = array('Yee', 'Dee', '16');
$rend = array('Last', 'Record', '1000');
/* Create the 2 dimensional array */
$arr = array($r0, $r1, $r2, $r3, $r4, $r5, $r0, $r1, $r2, $r3, $r4, $r5, $r0, $r1, $r2, $r3, $r4, $r5, $rend);
/* load the 2D array into a text database */
ADOLoadCode('text');
$db =& ADONewConnection();
if (empty($db)) {
    die("Cannot create ADONewConnection");
}
if (!$db->PConnect($arr, false, array('1stName', 'Surname', 'ID'))) {
    print 'Error:' . $db->ErrorMsg();
}
/* 
 * The id is very important. 
 * All phpLens objects should have a different id 
 */
$id = 'text_test';
$lens = new PHPLens($id, $db, 'select * from products');
if (empty($lens)) {
    die("Cannot create lens object id={$id}");

作者:qoir    项目:porta   
/**
  * Instantiate a new Connection class for a specific database driver.
  *
  * @param [db]  is the database Connection object to create. If undefined,
  * 	use the last database driver that was loaded by ADOLoadCode().
  *
  * @return the freshly created instance of the Connection class.
  */
 function &ADONewConnection($db = '')
 {
     global $ADODB_Database;
     if ($db) {
         if ($ADODB_Database != $db) {
             ADOLoadCode($db);
         }
     } else {
         if (!empty($ADODB_Database)) {
             $db = $ADODB_Database;
         } else {
             print "<p>ADONewConnection: No database driver defined</p>";
         }
     }
     $cls = 'ADODB_' . $db;
     return new $cls();
 }

作者:radicaldesign    项目:am   
function AMP_load_site_command_line()
{
    $local_path_pattern = '/home/%s/public_html/';
    #$local_path_pattern = '/home/%s/';
    $site_folder = $_SERVER['argv'][1];
    if (!$site_folder) {
        trigger_error('Usage: login_link.php sitename');
        return false;
    }
    define('AMP_LOCAL_PATH', sprintf($local_path_pattern, $site_folder));
    #define( 'AMP_SYSTEM_CACHE', false );
    $config_file_path = sprintf($local_path_pattern, $site_folder) . 'custom/';
    $lib_file_path = sprintf($local_path_pattern, $site_folder) . 'lib/';
    $include_path = sprintf($local_path_pattern, 'amp') . 'include/';
    $include_path = '/home/amp/public_html/include/';
    define('AMP_BASE_INCLUDE_PATH', $include_path);
    $config_file1 = 'SiteConfig.php';
    $config_file2 = 'config.php';
    $incpath = ini_get('include_path');
    // Search local paths for includes.
    ini_set('include_path', $include_path . ':' . $config_file_path . ':' . $lib_file_path . ':' . ini_get('include_path'));
    if (!file_exists($config_file_path . $config_file1) && !file_exists($config_file_path . $config_file2)) {
        trigger_error('path not found: ' . $config_file_path . $config_file2);
        return false;
    }
    require_once 'utility.system.functions.inc.php';
    require_once 'utility.functions.inc.php';
    require_once 'AMP/System/Flash.php';
    if (file_exists($config_file_path . $config_file1)) {
        require_once $config_file_path . $config_file1;
    } else {
        require_once $config_file_path . $config_file2;
        if (isset($MM_DBTYPE)) {
            define('AMP_DB_TYPE', $MM_DBTYPE);
        }
        define('AMP_DB_HOST', $MM_HOSTNAME);
        define('AMP_DB_USER', $MM_USERNAME);
        define('AMP_DB_PASS', $MM_PASSWORD);
        define('AMP_DB_NAME', $MM_DATABASE);
    }
    require_once 'adodb/adodb.inc.php';
    if (!defined('AMP_DB_TYPE')) {
        define('AMP_DB_TYPE', 'mysql');
    }
    ADOLoadCode(AMP_DB_TYPE);
    $dbcon = ADONewConnection(AMP_DB_TYPE);
    if (!$dbcon->Connect(AMP_DB_HOST, AMP_DB_USER, AMP_DB_PASS, AMP_DB_NAME)) {
        trigger_error('database connection failed');
        return false;
    }
    require_once 'AMP/Registry.php';
    $registry = AMP_Registry::instance();
    $registry->setDbcon($dbcon);
    //define( 'AMP_SYSTEM_CACHE', false );
    define('AMP_SITE_CACHE_TIMEOUT', 0);
    require_once 'AMP/System/Config.inc.php';
    require_once 'AMP/System/Language/Config.php';
    require_once 'AMP/Base/Debug.php';
    //require_once( 'AMP/System/Cache/Config.inc.php');
    AMP_config_load('cache');
    require_once 'AMP/Base/Setup.php';
    //require_once( 'AMP/System/User/Config.php');
    AMP_config_load('tools');
    require_once 'AMP/Base/Lookups.php';
    AMP_config_load('site');
    AMP_config_load('content');
    require_once 'AMP/Content/Map.inc.php';
    return $site_folder;
}

作者:manishkhanchandan    项目:mkgx   
print "ERROR: MSSQL test 2 requires a MS SQL 7 on a server='192.168.0.1', userid='adodb', password='natsoft', database='ai'" . '<BR>' . $db->ErrorMsg();
    }
}
ADOLoadCode('odbc_mssql');
if (!empty($testmssql)) {
    // MS SQL Server via ODBC
    $db = ADONewConnection();
    print "<h1>Connecting {$db->databaseType}...</h1>";
    $dsn = "PROVIDER=MSDASQL;Driver={SQL Server};Server={$server};Database=northwind;";
    if ($db->PConnect($dsn, "adodb", "natsoft", "")) {
        testdb($db, "create table ADOXYZ (id int, firstname char(24) null, lastname char(24) null,created datetime null)");
    } else {
        print "ERROR: MSSQL test 1 requires a MS SQL 7 server setup with DSN setup";
    }
}
ADOLoadCode("ado_mssql");
if (!empty($testmssql) && !empty($testado)) {
    // ADO ACCESS MSSQL -- thru ODBC -- DSN-less
    $db = ADONewConnection("ado_mssql");
    //$db->debug=1;
    print "<h1>Connecting DSN-less {$db->databaseType}...</h1>";
    $myDSN = "PROVIDER=MSDASQL;DRIVER={SQL Server};" . "SERVER={$server};DATABASE=NorthWind;UID=adodb;PWD=natsoft;Trusted_Connection=No";
    if ($db->PConnect($myDSN, "", "", "")) {
        testdb($db, "create table ADOXYZ (id int, firstname char(24) null, lastname char(24) null,created datetime null)");
    } else {
        print "ERROR: MSSQL test 2 requires MS SQL 7";
    }
}
if (!empty($testmssql) && !empty($testado)) {
    // ADO ACCESS MSSQL with OLEDB provider
    $db = ADONewConnection("ado_mssql");

作者:jackp    项目:ossim-ar   
function NewBASEDBConnection($path, $type)
{
    global $debug_mode;
    if (!($type == "mysql" || $type == "mysqli" || $type == "mysqlt" || $type == "maxsql" || $type == "postgres" || $type == "mssql" || $type == "oci8")) {
        require_once "classes/Util.inc";
        $errsqldbtypeinfo1 = gettext("The variable <CODE>\$DBtype</CODE> in <CODE>base_conf.php</CODE> was set to the unrecognized database type of ");
        $errsqldbtypeinfo2 = gettext("Only the following databases are supported: <PRE>\n                MySQL         : 'mysql'\n                MySQLi        : 'mysqli'\n                PostgreSQL    : 'postgres'\n                MS SQL Server : 'mssql'\n                Oracle        : 'oci8'\n             </PRE>");
        echo "<B>" . gettext("Invalid Database Type Specified") . "</B>" . "<P>:" . $errsqldbtypeinfo1 . "<CODE>'" . Util::htmlentities($type) . "'</CODE>. " . $errsqldbtypeinfo2;
        die;
    }
    /* Export ADODB_DIR for use by ADODB */
    /** Sometimes it may already be defined. So check to see if it is first -- Tim Rupp**/
    if (!defined('ADODB_DIR')) {
        define('ADODB_DIR', $path);
    }
    $GLOBALS['ADODB_DIR'] = $path;
    $last_char = substr($path, strlen($path) - 1, 1);
    // if ($debug_mode > 1) echo "Original path = '" . $path . "'<BR>";
    if ($last_char == "\\" || $last_char == "/") {
        // if ($debug_mode > 1) echo "Attempting to load: '" . $path . "adodb.inc.php'<BR>";
        VerifyDBAbstractionLib($path . "adodb.inc.php");
        include $path . "adodb.inc.php";
    } else {
        if (strstr($path, "/") || $path == "") {
            // if ($debug_mode > 1) echo "Attempting to load: '" . $path . "/adodb.inc.php'<BR>";
            VerifyDBAbstractionLib($path . "/adodb.inc.php");
            include $path . "/adodb.inc.php";
        } else {
            if (strstr($path, "\\")) {
                // if ($debug_mode > 1) echo "Attempting to load: '" . $path . "\\adodb.inc.php'<BR>";
                VerifyDBAbstractionLib($path . "\\adodb.inc.php");
                include $path . "\\adodb.inc.php";
            }
        }
    }
    ADOLoadCode($type);
    return new baseCon($type);
}

作者:dasatt    项目:dashboar   
/**
  * Instantiate a new Connection class for a specific database driver.
  *
  * @param [db]  is the database Connection object to create. If undefined,
  * 	use the last database driver that was loaded by ADOLoadCode().
  *
  * @return the freshly created instance of the Connection class.
  */
 function &ADONewConnection($db = '')
 {
     global $ADODB_NEWCONNECTION, $ADODB_LASTDB;
     if (!defined('ADODB_ASSOC_CASE')) {
         define('ADODB_ASSOC_CASE', 2);
     }
     $errorfn = defined('ADODB_ERROR_HANDLER') ? ADODB_ERROR_HANDLER : false;
     $false = false;
     if ($at = strpos($db, '://')) {
         $origdsn = $db;
         if (PHP_VERSION < 5) {
             $dsna = @parse_url($db);
         } else {
             $fakedsn = 'fake' . substr($db, $at);
             $dsna = @parse_url($fakedsn);
             $dsna['scheme'] = substr($db, 0, $at);
             if (strncmp($db, 'pdo', 3) == 0) {
                 $sch = explode('_', $dsna['scheme']);
                 if (sizeof($sch) > 1) {
                     $dsna['host'] = isset($dsna['host']) ? rawurldecode($dsna['host']) : '';
                     $dsna['host'] = rawurlencode($sch[1] . ':host=' . rawurldecode($dsna['host']));
                     $dsna['scheme'] = 'pdo';
                 }
             }
         }
         if (!$dsna) {
             // special handling of oracle, which might not have host
             $db = str_replace('@/', '@adodb-fakehost/', $db);
             $dsna = parse_url($db);
             if (!$dsna) {
                 return $false;
             }
             $dsna['host'] = '';
         }
         $db = @$dsna['scheme'];
         if (!$db) {
             return $false;
         }
         $dsna['host'] = isset($dsna['host']) ? rawurldecode($dsna['host']) : '';
         $dsna['user'] = isset($dsna['user']) ? rawurldecode($dsna['user']) : '';
         $dsna['pass'] = isset($dsna['pass']) ? rawurldecode($dsna['pass']) : '';
         $dsna['path'] = isset($dsna['path']) ? rawurldecode(substr($dsna['path'], 1)) : '';
         # strip off initial /
         if (isset($dsna['query'])) {
             $opt1 = explode('&', $dsna['query']);
             foreach ($opt1 as $k => $v) {
                 $arr = explode('=', $v);
                 $opt[$arr[0]] = isset($arr[1]) ? rawurldecode($arr[1]) : 1;
             }
         } else {
             $opt = array();
         }
     }
     /*
      *  phptype: Database backend used in PHP (mysql, odbc etc.)
      *  dbsyntax: Database used with regards to SQL syntax etc.
      *  protocol: Communication protocol to use (tcp, unix etc.)
      *  hostspec: Host specification (hostname[:port])
      *  database: Database to use on the DBMS server
      *  username: User name for login
      *  password: Password for login
      */
     if (!empty($ADODB_NEWCONNECTION)) {
         $obj = $ADODB_NEWCONNECTION($db);
     } else {
         if (!isset($ADODB_LASTDB)) {
             $ADODB_LASTDB = '';
         }
         if (empty($db)) {
             $db = $ADODB_LASTDB;
         }
         if ($db != $ADODB_LASTDB) {
             $db = ADOLoadCode($db);
         }
         if (!$db) {
             if (isset($origdsn)) {
                 $db = $origdsn;
             }
             if ($errorfn) {
                 // raise an error
                 $ignore = false;
                 $errorfn('ADONewConnection', 'ADONewConnection', -998, "could not load the database driver for '{$db}'", $db, false, $ignore);
             } else {
                 ADOConnection::outp("<p>ADONewConnection: Unable to load database driver '{$db}'</p>", false);
             }
             return $false;
         }
         $cls = 'ADODB_' . $db;
         if (!class_exists($cls)) {
             adodb_backtrace();
             return $false;
         }
//.........这里部分代码省略.........

作者:qoir    项目:porta   
'logos' => array('odbc','logos','','',''),
	'logos2' => array('odbc','logos2','','',''),
	'nwind' => array('access','nwind','','',''),
	'mysqlnwind' => array('mysql','192.168.0.1','root','','northwind')
);
*/
if (empty($PHPLENS_DATABASES)) {
    die("You must define the array PHPLENS_DATABASES to use the Grid Builder");
}
if (isset($HTTP_GET_VARS['driver'])) {
    $lens_qb_drivername = $HTTP_GET_VARS['driver'];
}
if (empty($lens_qb_drivername) || empty($PHPLENS_DATABASES[$lens_qb_drivername])) {
    $lens_qb_arr = reset($PHPLENS_DATABASES);
    $lens_qb_drivername = key($PHPLENS_DATABASES);
} else {
    $lens_qb_arr = $PHPLENS_DATABASES[$lens_qb_drivername];
}
$lens_qb_driver = $lens_qb_arr[0];
$lens_qb_server = $lens_qb_arr[1];
$lens_qb_user = $lens_qb_arr[2];
$lens_qb_pwd = $lens_qb_arr[3];
$lens_qb_database = $lens_qb_arr[4];
if (empty($lens_qb_id)) {
    $lens_qb_id = lens_qb_gen_id();
}
ADOLoadCode($lens_qb_driver);
$gDB = NewADOConnection();
if (!$gDB->PConnect($lens_qb_server, $lens_qb_user, $lens_qb_pwd, $lens_qb_database)) {
    $gDB = false;
}


问题


面经


文章

微信
公众号

扫码关注公众号