当前位置: 首页>>代码示例>>PHP>>正文


PHP ADONewConnection函数代码示例

本文整理汇总了PHP中ADONewConnection函数的典型用法代码示例。如果您正苦于以下问题:PHP ADONewConnection函数的具体用法?PHP ADONewConnection怎么用?PHP ADONewConnection使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ADONewConnection函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: DBConnect

function DBConnect()
{
    global $db;
    $db = ADONewConnection('mysql');
    $db->autoRollback = true;
    $db->PConnect(_DBHOST, _DBUSER, _DBPASS, _DBNAME) or die($db->ErrorMsg());
}
开发者ID:kreapptivo,项目名称:phprechnung,代码行数:7,代码来源:phprechnung.inc.php

示例2: getdb

/**
 * get ado-connection
 *
 * @return ado-connection
 */
function getdb()
{
    global $cfg;
    // build DSN
    switch ($cfg["db_type"]) {
        case "mysql":
            $dsn = 'mysql://' . $cfg["db_user"] . ':' . $cfg["db_pass"] . '@' . $cfg["db_host"] . '/' . $cfg["db_name"];
            if ($cfg["db_pcon"]) {
                $dsn .= '?persist';
            }
            break;
        case "sqlite":
            $dsn = 'sqlite://' . $cfg["db_host"];
            if ($cfg["db_pcon"]) {
                $dsn .= '/?persist';
            }
            break;
        case "postgres":
            $dsn = 'postgres://' . $cfg["db_user"] . ':' . $cfg["db_pass"] . '@' . $cfg["db_host"] . '/' . $cfg["db_name"];
            if ($cfg["db_pcon"]) {
                $dsn .= '?persist';
            }
            break;
        default:
            showErrorPage('No valid Database-Type specfied. <br>valid : mysql/sqlite/postgres<br>Check your database settings in the config.db.php file.');
    }
    // connect
    $db = @ADONewConnection($dsn);
    // check connection
    if (!$db) {
        showErrorPage('Could not connect to database :<br><em>' . $dsn . '</em><br>Check your database settings in the config.db.php file.');
    }
    // return db-connection
    return $db;
}
开发者ID:BackupTheBerlios,项目名称:tf-b4rt-svn,代码行数:40,代码来源:db.php

示例3: findSetDbDriver

 function findSetDbDriver($persistent)
 {
     switch (DB_API) {
         case "adodb":
             error_reporting(E_ALL);
             /*show all the error messages*/
             require_once 'adodb.inc.php';
             require_once 'adodb-pear.inc.php';
             global $ADODB_FETCH_MODE;
             $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
             if ($persistent == 0) {
                 $this->storeDbConnection =& ADONewConnection(DB_TYPE);
                 if (!$this->storeDbConnection->Connect(DB_HOST, DB_USER, DB_PASS, DB_NAME)) {
                     print DBErrorCodes::code1();
                     print $this->storeDConnection->ErrorMsg();
                 }
             } else {
                 $this->storeDbConnection =& ADONewConnection(DB_TYPE);
                 if (!isset($this->storeDbConnection)) {
                     if (!$this->storeDbConnection->PConnect(DB_HOST, DB_USER, DB_PASS, DB_NAME)) {
                         print ErrorCodes::code1();
                         print $this->storeDbConnection->ErrorMsg();
                     }
                 }
             }
             /*else*/
             break;
         default:
             print "Can't find the appropriate DB Abstraction Layer \n <BR>";
             break;
     }
     /*end switch*/
 }
开发者ID:nateirwin,项目名称:custom-historic,代码行数:33,代码来源:Connect.php

示例4: sess_open

 function sess_open($sess_path, $sess_name, $persist = null)
 {
     $database = $GLOBALS['ADODB_SESSION_DB'];
     $driver = $GLOBALS['ADODB_SESSION_DRIVER'];
     $host = $GLOBALS['ADODB_SESSION_CONNECT'];
     $password = $GLOBALS['ADODB_SESSION_PWD'];
     $user = $GLOBALS['ADODB_SESSION_USER'];
     $GLOBALS['ADODB_SESSION_TBL'] = !empty($GLOBALS['ADODB_SESSION_TBL']) ? $GLOBALS['ADODB_SESSION_TBL'] : 'sessions';
     $db_object =& ADONewConnection($driver);
     if ($persist) {
         switch ($persist) {
             default:
             case 'P':
                 $result = $db_object->PConnect($host, $user, $password, $database);
                 break;
             case 'C':
                 $result = $db_object->Connect($host, $user, $password, $database);
                 break;
             case 'N':
                 $result = $db_object->NConnect($host, $user, $password, $database);
                 break;
         }
     } else {
         $result = $db_object->Connect($host, $user, $password, $database);
     }
     if ($result) {
         $GLOBALS['ADODB_SESS_CONN'] =& $db_object;
     }
     return $result;
 }
开发者ID:briandodson,项目名称:bdcms,代码行数:30,代码来源:adodb-session.php

示例5: connect

 function connect()
 {
     if ($this->openqrm->get('config', 'DATABASE_TYPE') === "db2") {
         $db =& ADONewConnection('odbc');
         $db->PConnect($this->openqrm->get('config', 'DATABASE_NAME'), $this->openqrm->get('config', 'DATABASE_USER'), $this->openqrm->get('config', 'DATABASE_PASSWORD'));
         $db->SetFetchMode(ADODB_FETCH_ASSOC);
         return $db;
     } else {
         if ($this->openqrm->get('config', 'DATABASE_TYPE') === "oracle") {
             $db = NewADOConnection("oci8po");
             $db->Connect($this->openqrm->get('config', 'DATABASE_NAME'), $this->openqrm->get('config', 'DATABASE_USER'), $this->openqrm->get('config', 'DATABASE_PASSWORD'));
         } else {
             if (strlen($this->openqrm->get('config', 'DATABASE_PASSWORD'))) {
                 $dsn = $this->openqrm->get('config', 'DATABASE_TYPE') . '://';
                 $dsn .= $this->openqrm->get('config', 'DATABASE_USER') . ':';
                 $dsn .= $this->openqrm->get('config', 'DATABASE_PASSWORD') . '@';
                 $dsn .= $this->openqrm->get('config', 'DATABASE_SERVER') . '/';
                 $dsn .= $this->openqrm->get('config', 'DATABASE_NAME') . '?persist';
             } else {
                 $dsn = $this->openqrm->get('config', 'DATABASE_TYPE') . '://';
                 $dsn .= $this->openqrm->get('config', 'DATABASE_USER') . '@';
                 $dsn .= $this->openqrm->get('config', 'DATABASE_SERVER') . '/';
                 $dsn .= $this->openqrm->get('config', 'DATABASE_NAME') . '?persist';
             }
             $db =& ADONewConnection($dsn);
         }
     }
     $db->SetFetchMode(ADODB_FETCH_ASSOC);
     return $db;
 }
开发者ID:kelubo,项目名称:OpenQRM,代码行数:30,代码来源:db.class.php

示例6: connect

 public function connect()
 {
     $conn =& ADONewConnection('mysql');
     $conn->SetFetchMode(ADODB_FETCH_ASSOC);
     $conn->PConnect($GLOBALS['system']['host'], $GLOBALS['system']['user'], $GLOBALS['system']['pass'], $GLOBALS['system']['db']);
     return $conn;
 }
开发者ID:chriistiian,项目名称:phpexcel-adodb-report-generator,代码行数:7,代码来源:dbControl.class.php

示例7: getSettings

function getSettings($ontology_abbrv)
{
    global $driver, $host, $username, $password, $database;
    $settings = array();
    $strSql = "select * from ontology where ontology_abbrv='{$ontology_abbrv}'";
    $db = ADONewConnection($driver);
    $db->Connect($host, $username, $password, $database);
    $row = $db->GetRow($strSql);
    if (!empty($row)) {
        $settings['ontology_name'] = $row['ontology_abbrv'];
        $settings['ontology_fullname'] = $row['ontology_fullname'];
        $settings['ns_main'] = $row['ontology_graph_url'];
        $settings['ns_main_original'] = $row['ontology_url'];
        $settings['remote_store_endpoint'] = $row['end_point'];
    }
    $settings['ns_rdf'] = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#';
    $settings['ns_rdfs'] = 'http://www.w3.org/2000/01/rdf-schema#';
    $settings['ns_owl'] = 'http://www.w3.org/2002/07/owl#';
    $settings['base_oboInOwl'] = 'http://www.geneontology.org/formats/oboInOwl#';
    $settings['core_terms'] = array();
    $strSql = "select * from key_terms where ontology_abbrv='{$ontology_abbrv}' ORDER BY term_label";
    $results = $db->GetAll($strSql);
    if ($results != false) {
        foreach ($results as $result) {
            if ($result['is_root'] == 1) {
                $settings['core_terms'][$result['term_url']] = $result['term_label'] . ' (root class)';
            } else {
                $settings['core_terms'][$result['term_url']] = $result['term_label'];
            }
        }
    }
    return $settings;
}
开发者ID:e4ong1031,项目名称:ontobee,代码行数:33,代码来源:Classes.php

示例8: die

 function &Connect($info = NULL)
 {
     if (!(strtolower(substr(PHP_OS, 0, 3)) === 'win')) {
         // Non Windows platform
         die("Microsoft Access or SQL Server is supported on Windows server only.");
     }
     $GLOBALS["ADODB_FETCH_MODE"] = ADODB_FETCH_BOTH;
     $GLOBALS["ADODB_COUNTRECS"] = FALSE;
     $conn = ADONewConnection('ado_mssql');
     $conn->debug = $this->Debug;
     $conn->debug_echo = FALSE;
     if (!$info) {
         $info = "Provider=SQLNCLI11;Persist Security Info=False;Data Source=186.64.110.212;Initial Catalog=PbMillenium2;User Id=consultas;Password=consultas*;DataTypeCompatibility=80";
         // ADO connection string
     }
     if ($this->Debug) {
         $conn->raiseErrorFn = $GLOBALS["EW_ERROR_FN"];
     }
     if ($this->CodePage > 0) {
         $conn->charPage = $this->CodePage;
     }
     $conn->Connect($info, FALSE, FALSE);
     // Set date format
     $conn->Execute("SET DATEFORMAT ymd");
     $conn->raiseErrorFn = '';
     return $conn;
 }
开发者ID:erick-chali,项目名称:Ubicacion,代码行数:27,代码来源:Milleniumdb.php

示例9: openConnection

 function openConnection()
 {
     if ($this->connection == NULL) {
         require DIR_FS_CONFIG . "inc/config.php";
         $this->session_name = SESSION_NAME;
         $connection = ADONewConnection($db_management_system);
         if ($connection->PConnect($db_host, $db_user, $db_password, $db_name)) {
             $connection->debug = $debug;
             $this->connection = $connection;
             return true;
         } else {
             $this->setErrorMsg("DataBase connection error.");
             return false;
         }
     } else {
         if (is_a($this->connection, '__PHP_Incomplete_Class')) {
             require DIR_FS_CONFIG . "inc/config.php";
             $this->session_name = SESSION_NAME;
             $connection = ADONewConnection($db_management_system);
             if ($connection->PConnect($db_host, $db_user, $db_password, $db_name)) {
                 $connection->debug = $debug;
                 $this->connection = $connection;
                 return true;
             } else {
                 $this->setErrorMsg("DataBase connection error.");
                 return false;
             }
         } else {
             return true;
         }
     }
 }
开发者ID:nicolas34732,项目名称:address_book,代码行数:32,代码来源:Utils.class.php

示例10: getConnector

 public static final function getConnector($ctx, $connString)
 {
     $db = null;
     // SQLite db init
     if (strpos($connString, "sqlite") === 0) {
         $db =& ADONewConnection('sqlite');
         $db->debug = true;
         $connString = substr($connString, strlen("sqlite://"), strlen($connString));
         $db->PConnect($connString);
         $connectorClass = "SQLiteConnector";
     } else {
         if (strpos($connString, "mysql") === 0) {
             $db =& ADONewConnection($connectionString);
             $db->debug = true;
             $connectorClass = "MySQLConnector";
         }
     }
     if (!is_null($db) && $db->IsConnected()) {
         self::$log->debug("Detected DB type: " . $db->databaseType);
         $dbc = new $connectorClass($ctx, $db);
     } else {
         self::$log->error("Could not connect to DB ({$connString})");
         return false;
     }
     return $dbc;
 }
开发者ID:vladikius,项目名称:tephlon,代码行数:26,代码来源:DBCFactory.php

示例11: db_connect_real

function db_connect_real($host, $user, $pass, $db_name, $db_type, $port = "3306", $db_ssl = false, $retries = 20)
{
    global $cnn_id;
    $i = 0;
    $dsn = "{$db_type}://" . rawurlencode($user) . ":" . rawurlencode($pass) . "@" . rawurlencode($host) . "/" . rawurlencode($db_name) . "?persist";
    if ($db_ssl && $db_type == "mysql") {
        $dsn .= "&clientflags=" . MYSQL_CLIENT_SSL;
    } elseif ($db_ssl && $db_type == "mysqli") {
        $dsn .= "&clientflags=" . MYSQLI_CLIENT_SSL;
    }
    if ($port != "3306") {
        $dsn .= "&port=" . $port;
    }
    while ($i <= $retries) {
        $cnn_id = ADONewConnection($dsn);
        if ($cnn_id) {
            $cnn_id->EXECUTE("set names 'utf8'");
            return $cnn_id;
        }
        $i++;
        usleep(40000);
    }
    die("FATAL: Cannot connect to MySQL server on '{$host}'. Please make sure you have specified a valid MySQL database name in 'include/config.php'\n");
    return 0;
}
开发者ID:khoimt,项目名称:cacti-sample,代码行数:25,代码来源:database.php

示例12: connect_db

function connect_db($my_db_array, $db)
{
    global $db, $dbport, $ADODB_SESSION_DRIVER, $ADODB_SESSION_CONNECT, $ADODB_SESSION_DB, $ADODB_SESSION_USER, $ADODB_SESSION_PWD;
    //connect to database via adodb
    $ADODB_SESSION_DRIVER = $my_db_array['driver'];
    $ADODB_SESSION_DB = $my_db_array['database'];
    $ADODB_SESSION_USER = $my_db_array['db_user'];
    $ADODB_SESSION_PWD = $my_db_array['db_pass'];
    $ADODB_SESSION_CONNECT = $my_db_array['db_host'];
    $dbport = $my_db_array['port'];
    $db_prefix = $my_db_array['prefix'];
    $ADODB_NEVER_PERSIST = true;
    $ADODB_COUNTRECS = false;
    // This *deeply* improves the speed of adodb.
    if (!function_exists('mysql_connect')) {
        die("The mysql_connect function is not loaded - you need the php-mysql module installed for this game to function");
        return 0;
    }
    if (!empty($dbport)) {
        $ADODB_SESSION_CONNECT .= ":{$dbport}";
    }
    $db = ADONewConnection("{$ADODB_SESSION_DRIVER}");
    $db->debug = 0;
    $db->autoRollback = true;
    $result = $db->Connect("{$ADODB_SESSION_CONNECT}", "{$ADODB_SESSION_USER}", "{$ADODB_SESSION_PWD}", "{$ADODB_SESSION_DB}");
    if (!$result) {
        die("Unable to connect to the database: " . $db->ErrorMsg());
        return 0;
    }
    return $result;
}
开发者ID:BackupTheBerlios,项目名称:freechess-svn,代码行数:31,代码来源:game_functions.php

示例13: _init_adodb_library

 function _init_adodb_library(&$ci)
 {
     $db_var = false;
     $debug = false;
     $show_errors = true;
     $active_record = false;
     $db = NULL;
     if (!isset($dsn)) {
         // fallback to using the CI database file
         include APPPATH . 'config/database' . EXT;
         $group = 'default';
         $dsn = $db[$group]['dbdriver'] . '://' . $db[$group]['username'] . ':' . $db[$group]['password'] . '@' . $db[$group]['hostname'] . '/' . $db[$group]['database'];
     }
     // Show Message Adodb Library PHP
     if ($show_errors) {
         require_once BASEPATH . 'packages/adodb5/adodb-errorhandler.inc' . EXT;
     }
     // $ci is by reference, refers back to global instance
     $ci->adodb =& ADONewConnection($dsn);
     // Use active record adodbx
     $ci->adodb->setFetchMode(ADODB_FETCH_ASSOC);
     if ($db_var) {
         // Also set the normal CI db variable
         $ci->db =& $ci->adodb;
     }
     if ($active_record) {
         require_once BASEPATH . 'packages/adodb5/adodb-active-record.inc' . EXT;
         ADOdb_Active_Record::SetDatabaseAdapter($ci->adodbx);
     }
     if ($debug) {
         $ci->adodb->debug = true;
     }
 }
开发者ID:baltimoreteacher,项目名称:Grading,代码行数:33,代码来源:Adodbx.php

示例14: __construct

 private function __construct()
 {
     $db = ADONewConnection('mysql', 'pear:extend');
     $db->createdatabase = true;
     $db->Connect("jinahadam.db.4081957.hostedresource.com", "jinahadam", "Relevation#666", "jinahadam");
     $this->_handle =& $db;
 }
开发者ID:jinahadam,项目名称:Keystroke-Dynamics,代码行数:7,代码来源:Singleton.php

示例15: open

 /**
  * Opens connection to the database.
  * You must call this function after instanciating your class, before doing queries.
  * Otherways all queries will fail! You also must have authentificated a user, before
  * you can use this class!
  */
 function open($dbhost = "", $dbuser = "", $dbpasswd = "", $database = "")
 {
     global $c;
     // initialize configuratin variables.
     if ($dbhost == "") {
         $dbhost = $c["dbhost"];
     }
     if ($dbuser == "") {
         $dbuser = $c["dbuser"];
     }
     if ($dbpasswd == "") {
         $dbpasswd = $c["dbpasswd"];
     }
     if ($database == "") {
         $database = $c["database"];
     }
     if ($c["dbdriver"] == "mysql") {
         $this->ADODB = NewADOConnection($this->type);
         $this->ADODB->PConnect($dbhost, $dbuser, $dbpasswd, $database);
     } else {
         if ($c["dbdriver"] == "mssql") {
             $this->ADODB =& ADONewConnection("ado_mssql");
             $dsn = "PROVIDER=MSDASQL;DRIVER={SQL Server};SERVER=" . $dbhost . ";DATABASE=" . $database . ";UID=" . $dbuser . ";PWD=" . $dbpasswd . ";";
             $this->ADODB->Connect($dsn);
         }
     }
 }
开发者ID:BackupTheBerlios,项目名称:nxwcms-svn,代码行数:33,代码来源:database.php


注:本文中的ADONewConnection函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。