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


PHP msql_select_db函数代码示例

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


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

示例1: connect

 function connect($dsninfo, $persistent = false)
 {
     if (!DB::assertExtension('msql')) {
         return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND);
     }
     $this->dsn = $dsninfo;
     $user = $dsninfo['username'];
     $pw = $dsninfo['password'];
     $dbhost = $dsninfo['hostspec'] ? $dsninfo['hostspec'] : 'localhost';
     $connect_function = $persistent ? 'msql_pconnect' : 'msql_connect';
     if ($dbhost && $user && $pw) {
         $conn = $connect_function($dbhost, $user, $pw);
     } elseif ($dbhost && $user) {
         $conn = $connect_function($dbhost, $user);
     } else {
         $conn = $connect_function($dbhost);
     }
     if (!$conn) {
         $this->raiseError(DB_ERROR_CONNECT_FAILED);
     }
     if (!@msql_select_db($dsninfo['database'], $conn)) {
         return $this->raiseError(DB_ERROR_NODBSELECTED);
     }
     $this->connection = $conn;
     return DB_OK;
 }
开发者ID:vojtajina,项目名称:sitellite,代码行数:26,代码来源:msql.php

示例2: SelectDatabase

 function SelectDatabase()
 {
     if (!strcmp($this->database_name, "")) {
         return $this->SetError("Select database", "It was not specified a valid database name to select");
     }
     $last_connection = $this->connection;
     if (!$this->Connect()) {
         return 0;
     }
     if ($last_connection == $this->connection && strcmp($this->selected_database, "") && !strcmp($this->selected_database, $this->database_name)) {
         return 1;
     }
     if (!msql_select_db($this->database_name, $this->connection)) {
         return $this->SetError("Select database", msql_error());
     }
     $this->selected_database = $this->database_name;
     return 1;
 }
开发者ID:BackupTheBerlios,项目名称:zvs,代码行数:18,代码来源:metabase_msql.php

示例3: sql_connect

function sql_connect($host, $user, $password, $db)
{
    global $dbtype;
    switch ($dbtype) {
        case "MySQL":
            $dbi = @mysql_connect($host, $user, $password);
            mysql_select_db($db);
            return $dbi;
            break;
        case "mSQL":
            $dbi = msql_connect($host);
            msql_select_db($db);
            return $dbi;
            break;
        case "postgres":
            $dbi = @pg_connect("host={$host} user={$user} password={$password} port=5432 dbname={$db}");
            return $dbi;
            break;
        case "postgres_local":
            $dbi = @pg_connect("user={$user} password={$password} dbname={$db}");
            return $dbi;
            break;
        case "ODBC":
            $dbi = @odbc_connect($db, $user, $password);
            return $dbi;
            break;
        case "ODBC_Adabas":
            $dbi = @odbc_connect($host . ":" . $db, $user, $password);
            return $dbi;
            break;
        case "Interbase":
            $dbi = @ibase_connect($host . ":" . $db, $user, $password);
            return $dbi;
            break;
        case "Sybase":
            $dbi = @sybase_connect($host, $user, $password);
            sybase_select_db($db, $dbi);
            return $dbi;
            break;
        default:
            break;
    }
}
开发者ID:BackupTheBerlios,项目名称:domsmod-svn,代码行数:43,代码来源:sql_layer.php

示例4: OpenDataBase

function OpenDataBase($dbinfo)
{
    global $msql_db;
    if (!($dbc = msql_connect())) {
        $msg = gettext("Cannot establish connection to database, giving up.");
        $msg .= "<BR>";
        $msg .= sprintf(gettext("Error message: %s"), msql_error());
        ExitWiki($msg);
    }
    if (!msql_select_db($msql_db, $dbc)) {
        $msg = gettext("Cannot open database %s, giving up.");
        $msg .= "<BR>";
        $msg .= sprintf(gettext("Error message: %s"), msql_error());
        ExitWiki($msg);
    }
    $dbi['dbc'] = $dbc;
    $dbi['table'] = $dbinfo['table'];
    // page metadata
    $dbi['page_table'] = $dbinfo['page_table'];
    // page content
    return $dbi;
}
开发者ID:BackupTheBerlios,项目名称:oralux,代码行数:22,代码来源:msql.php

示例5: connect

 /**
  * Connect to the database server, log in and open the database
  *
  * Don't call this method directly.  Use DB::connect() instead.
  *
  * Example of how to connect:
  * <code>
  * require_once 'DB.php';
  * 
  * // $dsn = 'msql://hostname/dbname';  // use a TCP connection
  * $dsn = 'msql:///dbname';             // use a socket
  * $options = array(
  *     'portability' => DB_PORTABILITY_ALL,
  * );
  * 
  * $db =& DB::connect($dsn, $options);
  * if (PEAR::isError($db)) {
  *     die($db->getMessage());
  * }
  * </code>
  *
  * @param array $dsn         the data source name
  * @param bool  $persistent  should the connection be persistent?
  *
  * @return int  DB_OK on success. A DB_Error object on failure.
  */
 function connect($dsn, $persistent = false)
 {
     if (!PEAR::loadExtension('msql')) {
         return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND);
     }
     $this->dsn = $dsn;
     if ($dsn['dbsyntax']) {
         $this->dbsyntax = $dsn['dbsyntax'];
     }
     $params = array();
     if ($dsn['hostspec']) {
         $params[] = $dsn['port'] ? $dsn['hostspec'] . ',' . $dsn['port'] : $dsn['hostspec'];
     }
     $connect_function = $persistent ? 'msql_pconnect' : 'msql_connect';
     $ini = ini_get('track_errors');
     $php_errormsg = '';
     if ($ini) {
         $this->connection = @call_user_func_array($connect_function, $params);
     } else {
         ini_set('track_errors', 1);
         $this->connection = @call_user_func_array($connect_function, $params);
         ini_set('track_errors', $ini);
     }
     if (!$this->connection) {
         if (($err = @msql_error()) != '') {
             return $this->raiseError(DB_ERROR_CONNECT_FAILED, null, null, null, $err);
         } else {
             return $this->raiseError(DB_ERROR_CONNECT_FAILED, null, null, null, $php_errormsg);
         }
     }
     if (!@msql_select_db($dsn['database'], $this->connection)) {
         return $this->msqlRaiseError();
     }
     return DB_OK;
 }
开发者ID:BackupTheBerlios,项目名称:saecommerce,代码行数:61,代码来源:msql.php

示例6: sql_connect

function sql_connect($host, $user, $password, $db)
{
    global $dbtype;
    switch ($dbtype) {
        case "MySQL":
            $dbi = @mysql_connect($host, $user, $password);
            if (!mysql_select_db($db)) {
                mysql_query("CREATE DATABASE {$db}");
                mysql_select_db($db);
                include 'install.php';
                die;
            }
            return $dbi;
            break;
        case "mSQL":
            $dbi = msql_connect($host);
            if (!msql_select_db($db)) {
                msql_query("CREATE DATABASE {$db}");
                msql_select_db($db);
                include 'install.php';
                die;
            }
            return $dbi;
            break;
        case "PostgreSQL":
            $dbi = @pg_connect("host={$host} user={$user} password={$password} port=5432 dbname={$db}");
            return $dbi;
            break;
        case "PostgreSQL_local":
            $dbi = @pg_connect("user={$user} password={$password} dbname={$db}");
            return $dbi;
            break;
        case "ODBC":
            $dbi = @odbc_connect($db, $user, $password);
            return $dbi;
            break;
        case "ODBC_Adabas":
            $dbi = @odbc_connect($host . ":" . $db, $user, $password);
            return $dbi;
            break;
        case "Interbase":
            $dbi = @ibase_connect($host . ":" . $db, $user, $password);
            return $dbi;
            break;
        case "Sybase":
            $dbi = @sybase_connect($host, $user, $password);
            if (!sybase_select_db($db, $dbi)) {
                sybase_query("CREATE DATABASE {$db}", $dbi);
                sybase_select_db($db, $dbi);
                include 'install.php';
                die;
            }
            return $dbi;
            break;
        default:
            break;
    }
}
开发者ID:BackupTheBerlios,项目名称:jonescms,代码行数:58,代码来源:sql_layer.php

示例7: connect_msql

 function connect_msql($host, $user, $pass, $db)
 {
     $this->msql_link = msql_connect($host, $user, $pass);
     if ($this->msql_link == 0) {
         return false;
     }
     if (!msql_select_db($db, $this->msql_link)) {
         print "Database Error " . msql_error();
         return false;
     }
     return $this->msql_link;
 }
开发者ID:laiello,项目名称:cartonbank,代码行数:12,代码来源:phpMM_V_23_08_2007.php


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