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


PHP NewADOConnection函数代码示例

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


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

示例1: connexion_base

function connexion_base()
{
    $DB = NewADOConnection(BASE_TYPE);
    $DB->Connect(SERVEURBASE, USERBASE, USERPASSWD, BASE);
    //$DB->debug = true;
    return $DB;
}
开发者ID:BastienDurel,项目名称:OpenSondage,代码行数:7,代码来源:fonctions.php

示例2: Connect

 /**
  * Connect to database.
  */
 public static function Connect()
 {
     if (isset(self::$ado)) {
         //return forced new adodb connection
         $new = NewADOConnection(DATABASE_DRIVER);
         $new->autoRollback = true;
         // default is false
         if (!@$new->NConnect(DATABASE_HOST, DATABASE_USER, DATABASE_PASSWORD, DATABASE_NAME)) {
             throw new Exception("Connect to database failed");
         }
     } else {
         self::$ado = NewADOConnection(DATABASE_DRIVER);
         self::$ado->autoRollback = true;
         // default is false
         if (!@self::$ado->Connect(DATABASE_HOST, DATABASE_USER, DATABASE_PASSWORD, DATABASE_NAME)) {
             die("Connect to database failed");
         }
         $new = self::$ado;
     }
     if (self::is_mysql()) {
         // For MySQL
         $new->Execute('SET NAMES "utf8"');
     } elseif (self::is_postgresql()) {
         // For PostgreSQL
         @$new->Execute('SET bytea_output = "escape";');
     }
     return $new;
 }
开发者ID:62BRAINS,项目名称:EPESI,代码行数:31,代码来源:database.php

示例3: setup

 function setup()
 {
     if ($this->isType('mysql')) {
         if ($this->getCreateTarget() == true) {
             $this->connection =& NewADOConnection($this->dbConfig->getDBType());
             $ok = $this->connection->NConnect($this->dbConfig->getHostName(), $this->dbConfig->getRootUserName(), $this->dbConfig->getRootPassword());
             if (!$ok) {
                 throw new DatabaseBackupException(DatabaseBackupErrorCode::$DB_CONNECT_ERROR, DatabaseBackup::$langString['DestConnectFailed']);
             }
             // Drop database if already exists
             $sql = "drop database IF EXISTS " . $this->dbConfig->getDatabaseName();
             $result = $this->connection->Execute($sql);
             $this->checkError($result, $sql);
             $sql = 'create database ' . $this->dbConfig->getDatabaseName();
             if ($this->supportUTF8 == true) {
                 $sql .= " default character set utf8 default collate utf8_general_ci";
             }
             $result = $this->connection->Execute($sql);
             $this->checkError($result, $sql);
             $this->connection->Close();
         }
         $this->connection =& NewADOConnection($this->dbConfig->getDBType());
         $ok = $this->connection->NConnect($this->dbConfig->getHostName(), $this->dbConfig->getUserName(), $this->dbConfig->getPassword(), $this->dbConfig->getDatabaseName());
         if (!$ok) {
             throw new DatabaseBackupException(DatabaseBackupErrorCode::$DB_CONNECT_ERROR, DatabaseBackup::$langString['DestConnectFailed']);
         }
         $result = $this->connection->_Execute("SET interactive_timeout=28800", false);
         $result = $this->connection->_Execute("SET wait_timeout=28800", false);
         $result = $this->connection->_Execute("SET net_write_timeout=900", false);
     }
 }
开发者ID:casati-dolibarr,项目名称:corebos,代码行数:31,代码来源:Database.php

示例4: dbOpen

 /**
  * Open a connection to the database and set connection parameters
  * @param string $dbhost hostname where the database server uses
  * @param string $dbuser username to connect to the database
  * @param string $dbpass password to connect to the database
  * @param string $dbname
  * @param string $dbtype database driver to use, currently :
  *  "mysql", "mysqli","pdo_mysql" "pgsql", "pdo_pgsql" should work correctly.
  * @param string $dbprefix database prefix.
  */
 public function dbOpen($dbhost = '', $dbuser = '', $dbpass = '', $dbname = '', $dbtype = '', $dbprefix = '')
 {
     $this->dbtype = $dbtype;
     $this->dbprefix = $dbprefix;
     $ADODB_COUNTRECS = false;
     $this->dblink = NewADOConnection($this->dbtype);
     $this->dblink->Connect($dbhost, $dbuser, $dbpass, $dbname);
     if ($this->dblink === false || !empty($this->dbprefix) && !preg_match('/^[a-z][a-z0-9_]+$/i', $this->dbprefix)) {
         die('Flyspray was unable to connect to the database. ' . 'Check your settings in flyspray.conf.php');
     }
     $this->dblink->SetFetchMode(ADODB_FETCH_BOTH);
     /*
      * this will work only in the following systems/PHP versions
      *
      * PHP4 and 5 with postgresql
      * PHP5 with "mysqli" or "pdo_mysql" driver (not "mysql" driver)
      * using mysql 4.1.11 or later and mysql 5.0.6 or later.
      *
      * in the rest of the world, it will silently return FALSE.
      */
     $this->dblink->SetCharSet('utf8');
     //enable debug if constact DEBUG_SQL is defined.
     !defined('DEBUG_SQL') || ($this->dblink->debug = true);
     if ($dbtype === 'mysql' || $dbtype === 'mysqli') {
         $dbinfo = $this->dblink->ServerInfo();
         if (isset($dbinfo['version']) && version_compare($dbinfo['version'], '5.0.2', '>=')) {
             $this->dblink->Execute("SET SESSION SQL_MODE='TRADITIONAL'");
         }
     }
 }
开发者ID:canneverbe,项目名称:flyspray,代码行数:40,代码来源:class.database.php

示例5: smarty_modifier_glossary

function smarty_modifier_glossary($input)
{
    $plain = strtolower(preg_replace('/[^a-zA-Z0-9]+/', ' ', str_replace("'", '', strip_tags($input))));
    $words = preg_split('/ +/', $plain);
    $db = NewADOConnection($GLOBALS['DSN']);
    if (!$db) {
        die('Database connection failed');
    }
    print "<pre>{$plain}</pre>";
    $all = $db->getAssoc("select \n\tsource_word,\n\tgroup_concat(tran_word) as tran_word,\n\tgroup_concat(tran_lang) as tran_lang,\n\tgroup_concat(tran_dialect) as tran_dialect,\n\tgroup_concat(tran_definition) as tran_definition,\n\tgroup_concat(source_lang) as source_lang,\n\tgroup_concat(source_dialect) as source_dialect\n\tfrom glossary\n\tgroup by source_word");
    foreach ($all as $word => $row) {
        $wordregex = str_replace(')(*', '\\w*)(', str_replace('*)(', ')(\\w*', '(\\b)(' . $word . ')(\\b)'));
        if (strpos($row['tran_word'], ',') !== FALSE) {
            $tran_words = explode(',', $row['tran_word']);
            $tran_langs = explode(',', $row['tran_lang']);
            $tran_dialects = explode(',', $row['tran_dialect']);
            $tran_definitions = explode(',', $row['tran_definition']);
            $source_langs = explode(',', $row['source_lang']);
            $source_dialects = explode(',', $row['source_dialect']);
            $text = '';
            foreach ($tran_words as $i => $tran_word) {
                if ($text) {
                    $text .= "\n-------------------------------\n";
                }
                $text .= "Meaning: {$tran_word} ({$tran_langs[$i]} {$tran_dialects[$i]})\n{$tran_definitions[$i]}\n Source: {$source_langs[$i]} {$source_dialects[$i]}";
            }
        } else {
            $text = "Meaning: {$row['tran_word']} ({$row['tran_lang']} {$row['tran_dialect']})\n{$row['tran_definition']}\n Source: {$row['source_lang']} {$row['source_dialect']}";
        }
        $input = preg_replace('/' . $wordregex . '/i', "\$1<acronym title=\"{$text}\">\$2</acronym>\$3", $input);
    }
    return $input;
}
开发者ID:s-a-r-id,项目名称:geograph-project,代码行数:33,代码来源:glossary.php

示例6: getConnID

 function getConnID()
 {
     require_once 'library/adodb/adodb.inc.php';
     //导入ADODB类库
     $this->connID = NewADOConnection($this->dbType);
     //生成数据库连接对象
     if ($this->dbType == 'mysql' || $this->dbType == 'mssql') {
         //如果为MySQL数据库或者SQL Server数据库
         $this->connID->Connect($this->host, $this->userName, $this->password, $this->dbName);
         //通过Connect()方法建立与数据库连接
         if ($this->dbType == 'mysql') {
             $this->connID->Execute('set names gb2312');
             //设置数据库编码
         }
     } elseif ($this->dbType == 'access') {
         //如过为ACCESS数据库
         $this->connID->Connect('Driver = {Microsoft Access Driver (*.mdb)}; Dbq =' . realpath($this->dbName) . ';Uid = ' . $this->userName . ';Pwd = ' . $this->password . ';');
     } else {
         return false;
     }
     $this->connID->debug = $this->isDebug;
     //是否调试
     return $this->connID;
     //返回数据库连接对象
 }
开发者ID:Arrray,项目名称:PHPpractice,代码行数:25,代码来源:ConnDB.php

示例7: md5

    /**
    * Gets an instance of AdoDb database connection
    *
    * Whenever a database connection is required you can get a
    * reference to the default database connection by doing:
    *
    * $db =& Ak:db(); // get an adodb instance
    * 
    * AdoDB manual can be found at http://phplens.com/adodb/
    *
    * @access public
    * @param    string    $dns    A string containing Data Source Name (information
    * regarding database connection)
    * http://phplens.com/adodb/code.initialization.html#dsnsupport
    * @static
    * @return resource Php AdoDb instance.
    */
    function &db($dsn = null, $connection_id = null)
    {
        static $db, $default_connection_id;

        // In order to retrieve a database connection we just need to provide its identifier
        if(empty($default_connection_id)){
            $default_connection_id = md5($dsn);
        }
        $connection_id = empty($connection_id) ? $default_connection_id : $connection_id;
        
        if(empty($db[$connection_id])){
            require_once(AK_CONTRIB_DIR.DS.'adodb'.DS.'adodb.inc.php');

            if(substr($dsn, 0, 6) == 'mysql:'){
                $dsn = substr_replace($dsn, 'mysqlt:', 0, 6);
            }

            if (!$db[$connection_id] = (AK_DEBUG ? NewADOConnection($dsn) : @NewADOConnection($dsn))){
                error_reporting(E_ALL);
                if(defined('AK_DATABASE_CONNECTION_FAILURE_CALLBACK') && function_exists(AK_DATABASE_CONNECTION_FAILURE_CALLBACK)){
                    $fn = AK_DATABASE_CONNECTION_FAILURE_CALLBACK;
                    $fn();
                }
                if(!AK_PHP5 && substr($dsn,0,6) == 'sqlite'){
                    echo "\nWarning, sqlite support is not available by default on PHP4.\n Check your PHP version by running \"env php -v\", and change the first line in your scripts/ so they point to a php5 binary\n\n";
                }
                die(Ak::t('Connection to the database failed.').' '.
                (AK_DEBUG?preg_replace('/\/\/(\w+):(.*)@/i','//$1:******@', urldecode($dsn))."\n":''));
            }
            $db[$connection_id]->debug = AK_DEBUG == 2;
            defined('AK_DATABASE_CONNECTION_AVAILABLE') ? null : define('AK_DATABASE_CONNECTION_AVAILABLE', true);
            $dsn = '';
        }
        return $db[$connection_id];
    }
开发者ID:joeymetal,项目名称:v1,代码行数:52,代码来源:Ak.php

示例8: bBlog

 function bBlog()
 {
     // connect to database
     $this->_adb = NewADOConnection('mysql://' . DB_USERNAME . ':' . DB_PASSWORD . '@' . DB_HOST . '/' . DB_DATABASE . '?persist');
     //$this->_db = new db(DB_USERNAME, DB_PASSWORD, DB_DATABASE, DB_HOST);
     $this->num_rows =& $this->_db->num_rows;
     $this->insert_id =& $this->_db->insert_id;
     //Load the config
     $config =& new configHandler($this->_adb);
     $config->loadConfig();
     $this->assign('blogname', C_BLOGNAME);
     $this->assign('blogdescription', C_BLOG_DESCRIPTION);
     $this->assign('blogurl', BLOGURL);
     $this->assign('bblogurl', BBLOGURL);
     $this->assign('metakeywords', C_META_KEYWORDS);
     $this->assign('metadescription', C_META_DESCRIPTION);
     $this->assign('charset', C_CHARSET);
     $this->assign('direction', C_DIRECTION);
     $this->assign('C_CAPTCHA_ENABLE', C_CAPTCHA_ENABLE);
     // initial time from config table, based on last updated stuff.
     // this is just the initial value.
     //$this->lastmodified = C_LAST_MODIFIED;
     //$this->register_postfilter("update_when_compiled");
     // load up the sections
     $this->get_sections();
     //start the session that we need so much ;)
     if (!session_id()) {
         session_start();
     }
     $this->_ph =& new postHandler(&$this->_adb);
     Smarty::Smarty();
 }
开发者ID:BackupTheBerlios,项目名称:loquacity-svn,代码行数:32,代码来源:bBlog.class.php

示例9: open

 /**
  * Establishes a DB connection
  * @access public
  * @return bool
  */
 public function open()
 {
     // check if connected already
     if ($this->db) {
         return true;
     }
     // need adodb and exceptions
     include_once EP_LIBS_ADODB . '/adodb-exceptions.inc.php';
     include_once EP_LIBS_ADODB . '/adodb.inc.php';
     // connect db now
     try {
         // $this->db = & ADONewConnection($this->dsn);
         $this->db =& NewADOConnection('pdo');
         // convert PEAR DSN into PDO DSN
         $dsn_pdo = $this->_convertDsn($this->dsn, $username, $password, $phptype);
         // set db type
         $this->_setDbType($phptype);
         // connect through PDO
         $this->db->Connect($dsn_pdo, $username, $password);
     } catch (Exception $e) {
         throw new epExceptionDbAdodb('Cannot connect db: ' . $e->getMessage());
         return false;
     }
     // set fetch mode to assoc
     $this->db->SetFetchMode(ADODB_FETCH_ASSOC);
     return true;
 }
开发者ID:justinlyon,项目名称:scc,代码行数:32,代码来源:epDbAdodbPdo.php

示例10: make_db

/**
 * This function creates the DB on new installs
 */
function make_db($dbhost, $dbuname, $dbpass, $dbname, $prefix_table, $dbtype, $dbmake)
{
    global $db;
    echo '<font class="oos-title">' . INPUT_DATA . '</font>';
    echo '<table align="center"><tr><td align="left">';
    if ($dbmake) {
        $db =& NewADOConnection($dbtype);
        $dbh = $db->Connect($dbhost, $dbuname, $dbpass);
        if (!$dbh) {
            $dbpass = "";
            die("{$dbtype}://{$dbuname}:{$dbpass}@{$dbhost} failed to connect" . $db->ErrorMsg());
        }
        $dict = NewDataDictionary($db);
        if (!$dict) {
            continue;
        }
        $dict->debug = 1;
        // ToDo CREATE DATABASE $dbname DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
        $sqlarray = $dict->CreateDatabase($dbname);
        $dict->ExecuteSQLArray($sqlarray);
    }
    oosDBInit($dbhost, $dbuname, $dbpass, $dbname, $dbtype);
    if (!$prefix_table == '') {
        $prefix_table = $prefix_table . '_';
    }
    include 'newtables.php';
    echo '</td></tr></table>';
}
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:31,代码来源:newinstall.php

示例11: 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

示例12: DbConnect

 /** Connect this object to the database! */
 function DbConnect()
 {
     $ADODB_CACHE_DIR = '/tmp';
     /*	$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;	*/
     require_once 'adodb/adodb.inc.php';
     if ($this->ini_cfg['database']['dbtype'] == "postgres") {
         if (isset($this->ini_cfg["database"]['hostname']) && strlen($this->ini_cfg["database"]['hostname']) > 0) {
             $datasource = 'pgsql://' . $this->ini_cfg["database"]['user'] . ':' . $this->ini_cfg["database"]['password'] . '@' . $this->ini_cfg["database"]['hostname'] . '/' . $this->ini_cfg["database"]['dbname'];
         } else {
             $datasource = 'pgsql://dbname=' . $this->ini_cfg["database"]['dbname'] . ' user=' . $this->ini_cfg["database"]['user'];
             if (strlen($this->ini_cfg["database"]['password'])) {
                 $datasource .= ' password=' . $this->ini_cfg["database"]['password'];
             }
         }
     } else {
         $datasource = 'mysql://' . $this->ini_cfg['database']['user'] . ':' . $this->ini_cfg['database']['password'] . '@' . $this->ini_cfg['database']['hostname'] . '/' . $this->ini_cfg['database']['dbname'];
     }
     //echo "Datasource: $datasource \n";
     $this->dbhandle = NewADOConnection($datasource);
     if (!$this->dbhandle) {
         return false;
     }
     $this->dbhandle->setFetchMode(ADODB_FETCH_ASSOC);
     return true;
 }
开发者ID:sayemk,项目名称:a2billing,代码行数:26,代码来源:Class.A2Billing.inc.php

示例13: ConnectionHandler

 function ConnectionHandler($ruta_raiz)
 {
     if (!defined('ADODB_ASSOC_CASE')) {
         define('ADODB_ASSOC_CASE', 1);
     }
     include "{$ruta_raiz}/adodb/adodb.inc.php";
     include_once "{$ruta_raiz}/adodb/adodb-paginacion.inc.php";
     include_once "{$ruta_raiz}/adodb/tohtml.inc.php";
     include "{$ruta_raiz}/config.php";
     $ADODB_COUNTRECS = false;
     $this->driver = $driver;
     //$dsn= $driver.'://'.$usuario.':'.$contrasena.'@'.$servidor.'/'.$servicio;
     $this->conn = NewADOConnection($driver);
     //	$this->conn->debug=true;
     $this->rutaRaiz = $ruta_raiz;
     if (!$this->conn or $this->conn->Connect($servidor, $usuario, $contrasena, $servicio) == false) {
         die("Error de conexi&oacute;n a la B.D. comun&iacute;quese con el Administrador");
     }
     $this->entidad = $entidad;
     $this->entidad_largo = $entidad_largo;
     $this->entidad_tel = $entidad_tel;
     $this->entidad_dir = $entidad_dir;
     if ($this->driver == 'mssql') {
         $this->conn->query("Set DateFirst 1");
     }
 }
开发者ID:kractos26,项目名称:orfeo,代码行数:26,代码来源:ConnectionHandler.php

示例14: connect

 /**
  * connect to database
  * @param $host
  * @param $user
  * @param $pass
  * @param $dbname
  */
 public static function connect($host, $user, $pass, $dbname)
 {
     global $DB;
     $DB = NewADOConnection('mysql');
     $conn = $DB->Connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
     return $conn;
 }
开发者ID:hoangsoft90,项目名称:cpanel-manager,代码行数:14,代码来源:database.class.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


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