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


PHP db_select_db函数代码示例

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


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

示例1: init

function init()
{
    global $HTTP_POST_VARS, $HTTP_GET_VARS, $PARAM;
    global $debugFP, $dbh, $dbuser, $dbhost, $dbport, $dbpass, $dbname, $debugLogFile;
    //assume that the variables order is "GP"
    $PARAM = array_merge($_GET, $_POST);
    if (defined('DEBUG') && DEBUG == 1) {
        // If DEBUG is true, try to open log file:
        if (!($debugFP = @fopen($debugLogFile, "a"))) {
            // fopen failed, set program status:
            setLogAndStatus('', '', $debugLogFile, 'init()', 'DEBUG_LOG_OPEN');
            return 0;
        }
    }
    if (!($dbh = db_connect("{$dbhost}:{$dbport}", $dbuser, $dbpass))) {
        // database connection failed, set program status:
        setLogAndStatus('', db_errno($dbh), db_error($dbh), 'init()', 'DB_CONNECT');
        return 0;
    }
    if (!db_select_db($dbname, $dbh)) {
        // database selection failed, set program status:
        setLogAndStatus('', db_errno($dbh), db_error($dbh), 'init()', 'DB_SELECT');
        return 0;
    }
    //mysql_query('set names utf8');
    session_name('diploma');
    session_start('');
    return 1;
}
开发者ID:kktsvetkov,项目名称:1double.com,代码行数:29,代码来源:shared.inc.php

示例2: saveSld

/**
 * This function saves the data into the database
 * @param string $data the content of the sld-document to be stored inside the database
 */
function saveSld($data)
{
    $con = db_connect($DBSERVER, $OWNER, $PW);
    db_select_db($DB, $con);
    $sql = "UPDATE sld_user_layer SET sld_xml=\$1 WHERE fkey_gui_id=\$2 AND fkey_layer_id=\$3 AND fkey_mb_user_id=\$4";
    $v = array($data, $_SESSION["sld_gui_id"], $_SESSION["sld_layer_id"], $_SESSION["mb_user_id"]);
    $t = array('s', 's', 'i', 'i');
    $res = db_prep_query($sql, $v, $t);
}
开发者ID:bfpi,项目名称:klarschiff-frontend-mit-mapbender,代码行数:13,代码来源:sld_function_handler.php

示例3: db_pconnect

function db_pconnect($p_hostname = "localhost", $p_username = "root", $p_password = "", $p_database = "mantis", $p_port = 3306)
{
    $t_result = mysql_pconnect($p_hostname . ":" . $p_port, $p_username, $p_password);
    if (!$t_result) {
        echo "ERROR: FAILED CONNECTION TO DATABASE: ";
        echo db_error();
        exit;
    }
    $t_result = db_select_db($p_database);
    if (!$t_result) {
        echo "ERROR: FAILED DATABASE SELECTION: ";
        echo db_error();
        exit;
    }
}
开发者ID:ColBT,项目名称:php_tut,代码行数:15,代码来源:core_database_API.php

示例4: authenticate

function authenticate($name, $pw)
{
    $con = db_connect(DBSERVER, OWNER, PW);
    db_select_db(DB, $con);
    $sql = "SELECT * FROM mb_user WHERE mb_user_name = \$1 AND mb_user_password = \$2";
    $v = array($name, md5($pw));
    // is md5 used really?
    $t = array('s', 's');
    $res = db_prep_query($sql, $v, $t);
    if ($row = db_fetch_array($res)) {
        $e = new mb_exception('row mb_user_name: ' . $row['mb_user_name']);
        return $row;
    } else {
        return false;
    }
}
开发者ID:bfpi,项目名称:klarschiff-frontend-mit-mapbender,代码行数:16,代码来源:authentication.php

示例5: db_test_create_db_permission

function db_test_create_db_permission($database) {
    global $db_error;
    $db_created = false;
    $db_error = false;
    if (!$database) {
        $db_error = 'No Database selected.';
        return false;
    }
    if ($db_error) {
        return false;
    } else {
        if (!@db_select_db($database)) {
            $db_error = mysql_error();
            return false;
        }else {
            return true;
        }
    return true;
    }
}
开发者ID:ntoombs19,项目名称:newbietuesdays,代码行数:20,代码来源:mysql_test.php

示例6: init

function init()
{
    global $HTTP_POST_VARS, $HTTP_GET_VARS, $PARAM;
    global $debugFP, $dbh, $dbuser, $dbhost, $dbport, $dbpass, $dbname, $debugLogFile;
    ////---- [Mrasnika's] Edition Aug-01-2008
    global $Cache;
    $Cache = new Cache('CACHE2_');
    //assume that the variables order is "GP"
    $PARAM = array_merge($_GET, $_POST);
    if (defined('DEBUG') && DEBUG == 1) {
        // If DEBUG is true, try to open log file:
        if (!($debugFP = @fopen($debugLogFile, "a"))) {
            // fopen failed, set program status:
            setLogAndStatus('', '', $debugLogFile, 'init()', 'DEBUG_LOG_OPEN');
            ////---- [Mrasnika's] Edition Aug-01-2008
            //return 0;
            $Cache->force();
        }
    }
    if (!($dbh = @db_connect("{$dbhost}:{$dbport}", $dbuser, $dbpass))) {
        // database connection failed, set program status:
        setLogAndStatus('', db_errno($dbh), db_error($dbh), 'init()', 'DB_CONNECT');
        ////---- [Mrasnika's] Edition Aug-01-2008
        //return 0;
        $Cache->force();
    }
    if (!@db_select_db($dbname, $dbh)) {
        // database selection failed, set program status:
        setLogAndStatus('', db_errno($dbh), db_error($dbh), 'init()', 'DB_SELECT');
        ////---- [Mrasnika's] Edition Aug-01-2008
        //return 0;
        $Cache->force();
    }
    //mysql_query('set names utf8');
    ////----[Mrasnika's] Edition 20.06.2003
    if (!defined('INDEX')) {
        session_name('v');
        session_start('');
    }
    return 1;
}
开发者ID:kktsvetkov,项目名称:1double.com,代码行数:41,代码来源:shared.inc.php

示例7: getKmlDocumentFromDB

 /**
  * @param  integer  the ID of the KML.
  * @return string   the KML document with the given ID.
  */
 public function getKmlDocumentFromDB($kmlId)
 {
     $con = db_connect(DBSERVER, OWNER, PW);
     db_select_db(DB, $con);
     //get KML from database (check if user is allowed to access)
     # for now, do not restrict access
     #		$sql = "SELECT kml_doc FROM gui_kml WHERE kml_id = $1 AND fkey_mb_user_id = $2 AND fkey_gui_id = $3 LIMIT 1";
     #		$v = array($kmlId, Mapbender::session()->get("mb_user_id"), Mapbender::session()->get("mb_user_gui"));
     #		$t = array("i", "i", "s");
     $sql = "SELECT kml_doc FROM gui_kml WHERE kml_id = \$1 LIMIT 1";
     $v = array($kmlId);
     $t = array("i");
     $result = db_prep_query($sql, $v, $t);
     $row = db_fetch_array($result);
     if ($row) {
         return $row["kml_doc"];
     } else {
         $e = new mb_exception("class_kml.php: getKMLDocumentFromDB: no KML found for ID " . $kmlId);
     }
     return "";
 }
开发者ID:bfpi,项目名称:klarschiff-frontend-mit-mapbender,代码行数:25,代码来源:class_kml_ows.php

示例8: dirname

<?php

require dirname(__FILE__) . "/../../conf/mapbender.conf";
require dirname(__FILE__) . "/../../http/classes/class_administration.php";
require dirname(__FILE__) . "/../../http/classes/class_connector.php";
require_once dirname(__FILE__) . "/../../http/classes/class_mb_exception.php";
require dirname(__FILE__) . "/../../owsproxy/http/classes/class_QueryHandler.php";
//database connection
$db = db_connect($DBSERVER, $OWNER, $PW);
db_select_db(DB, $db);
$imageformats = array("image/png", "image/gif", "image/jpeg", "image/jpg");
//control if digest auth is set, if not set, generate the challenge with getNonce()
if (empty($_SERVER['PHP_AUTH_DIGEST'])) {
    header('HTTP/1.1 401 Unauthorized');
    header('WWW-Authenticate: Digest realm="' . REALM . '",qop="auth",nonce="' . getNonce() . '",opaque="' . md5(REALM) . '"');
    die('Text to send if user hits Cancel button');
}
//read out the header in an array
$requestHeaderArray = http_digest_parse($_SERVER['PHP_AUTH_DIGEST']);
//error if header could not be read
if (!$requestHeaderArray) {
    echo 'Following Header information cannot be validated - check your clientsoftware!<br>';
    echo $_SERVER['PHP_AUTH_DIGEST'] . '<br>';
    die;
}
//get mb_username and email out of http_auth username string
$userIdentification = explode(';', $requestHeaderArray['username']);
$mbUsername = $userIdentification[0];
$mbEmail = $userIdentification[1];
$userInformation = getUserInfo($mbUsername, $mbEmail);
if ($userInformation[0] == '-1') {
开发者ID:bfpi,项目名称:klarschiff-frontend-mit-mapbender,代码行数:31,代码来源:index.php

示例9: sql

 function sql($statment, &$o)
 {
     static $connected = false, $db_link;
     // $connect would be set to true on successful connection
     if (!$connected) {
         /****** Connect to MySQL ******/
         if (!($db_link = @db_connect(config('dbServer'), config('dbUsername'), config('dbPassword')))) {
             echo "<div class=\"alert alert-danger\">Couldn't connect to MySQL at '" . config('dbServer') . "'. You might need to re-configure this application. You can do so by manually editing the config.php file, or by deleting it to run the setup wizard.</div>";
             exit;
         }
         /****** Select DB ********/
         if (!db_select_db(config('dbDatabase'), $db_link)) {
             echo "<div class=\"alert alert-danger\">Couldn't connect to the database '" . config('dbDatabase') . "'.</div>";
             exit;
         }
         $connected = true;
     }
     if (!($result = @db_query($statment))) {
         echo "An error occured while attempting to execute:<br><pre>" . htmlspecialchars($statment) . "</pre><br>MySQL said:<br><pre>" . db_error(db_link()) . "</pre>";
         exit;
     }
     return $result;
 }
开发者ID:TokaMElTorkey,项目名称:northwind,代码行数:23,代码来源:incFunctions.php

示例10: elseif

        if ($password != $confirmPassword) {
            $errors[] = $Translation['password no match'];
        }
        if (!$email) {
            $errors[] = $Translation['email invalid'];
        }
    }
    /* test database connection */
    if (!($connection = @db_connect($db_server, $db_username, $db_password))) {
        $errors[] = $Translation['Database connection error'];
    }
    if ($connection !== false && !@db_select_db($db_name, $connection)) {
        // attempt to create the database
        if (!@db_query("CREATE DATABASE IF NOT EXISTS `{$db_name}`")) {
            $errors[] = @db_error($connection);
        } elseif (!@db_select_db($db_name, $connection)) {
            $errors[] = @db_error($connection);
        }
    }
    /* in case of validation errors, output them and exit */
    if (count($errors)) {
        if ($test) {
            echo 'ERROR!';
            exit;
        }
        ?>
				<div class="row">
					<div class="col-md-8 col-md-offset-2 col-lg-6 col-lg-offset-3">
						<h2 class="text-danger"><?php 
        echo $Translation['The following errors occured'];
        ?>
开发者ID:vishwanathhsinhaa,项目名称:tieuthuong-org,代码行数:31,代码来源:setup.php

示例11: sql

function sql($statment, &$o)
{
    /*
    	Supported options that can be passed in $o options array (as array keys):
    	'silentErrors': If true, errors will be returned in $o['error'] rather than displaying them on screen and exiting.
    */
    global $Translation;
    static $connected = false, $db_link;
    $dbServer = config('dbServer');
    $dbUsername = config('dbUsername');
    $dbPassword = config('dbPassword');
    $dbDatabase = config('dbDatabase');
    ob_start();
    if (!$connected) {
        /****** Connect to MySQL ******/
        if (!extension_loaded('mysql') && !extension_loaded('mysqli')) {
            echo error_message('PHP is not configured to connect to MySQL on this machine. Please see <a href="http://www.php.net/manual/en/ref.mysql.php">this page</a> for help on how to configure MySQL.');
            $e = ob_get_contents();
            ob_end_clean();
            if ($o['silentErrors']) {
                $o['error'] = $e;
                return FALSE;
            } else {
                echo $e;
                exit;
            }
        }
        if (!($db_link = @db_connect($dbServer, $dbUsername, $dbPassword))) {
            echo error_message(db_error($db_link, true));
            $e = ob_get_contents();
            ob_end_clean();
            if ($o['silentErrors']) {
                $o['error'] = $e;
                return FALSE;
            } else {
                echo $e;
                exit;
            }
        }
        /****** Select DB ********/
        if (!db_select_db($dbDatabase, $db_link)) {
            echo error_message(db_error($db_link));
            $e = ob_get_contents();
            ob_end_clean();
            if ($o['silentErrors']) {
                $o['error'] = $e;
                return FALSE;
            } else {
                echo $e;
                exit;
            }
        }
        $connected = true;
    }
    if (!($result = @db_query($statment, $db_link))) {
        if (!stristr($statment, "show columns")) {
            // retrieve error codes
            $errorNum = db_errno($db_link);
            $errorMsg = db_error($db_link);
            echo error_message(htmlspecialchars($errorMsg) . "\n\n<!--\n" . $Translation['query:'] . "\n {$statment}\n-->\n\n");
            $e = ob_get_contents();
            ob_end_clean();
            if ($o['silentErrors']) {
                $o['error'] = $errorMsg;
                return false;
            } else {
                echo $e;
                exit;
            }
        }
    }
    ob_end_clean();
    return $result;
}
开发者ID:WebxOne,项目名称:fwldba,代码行数:74,代码来源:incCommon.php

示例12: VALUES

	global $session;
	$sql = "DELETE from debuglog WHERE date <'".date("Y-m-d H:i:s",strtotime("-".(getsetting("expirecontent",180)/10)." days"))."'";
	db_query($sql);
	$sql = "INSERT INTO debuglog VALUES(0,now(),{$session['user']['acctid']},$target,'".addslashes($message)."')";
	db_query($sql);
}

if (file_exists("dbconnect.php")){
	require_once "dbconnect.php";
}else{
	echo "You must edit the file named \"dbconnect.php.dist,\" and provide the requested information, then save it as \"dbconnect.php\"".
	exit();
}

$link = db_pconnect($DB_HOST, $DB_USER, $DB_PASS) or die (db_error($link));
db_select_db ($DB_NAME) or die (db_error($link));
define("LINK",$link);

require_once "translator.php";


session_register("session");
function register_global(&$var){
	@reset($var);
	while (list($key,$val)=@each($var)){
		global $$key;
		$$key = $val;
	}
	@reset($var);
}
$session =& $_SESSION['session'];
开发者ID:BackupTheBerlios,项目名称:dragonsaga-svn,代码行数:31,代码来源:common.php

示例13: cw_cpanel_install_tables

function cw_cpanel_install_tables($params)
{
    global $var_dirs, $mysql_connection_id;
    $current_connection = $mysql_connection_id;
    $ret = @db_connect($params['mysql_host'], $params['mysql_user'], $params['mysql_password']);
    if ($ret) {
        $ret &= db_select_db($params['mysql_db']);
    }
    if (!$ret) {
        $mysql_connection_id = $current_connection;
        cw_cpanel_install_show_status('db_connect', $file, false);
        return false;
    }
    $new_connection = $mysql_connection_id;
    $file_path = $var_dirs['repository'] . '/sql';
    $files = array('ars_tables.sql', 'ars_data.sql');
    foreach ($files as $file) {
        $fp = @fopen($file_path . '/' . $file, "rb");
        if ($fp === false) {
            $mysql_connection_id = $current_connection;
            cw_cpanel_install_show_status('read_db_file', $file, false);
            return false;
        }
        $command = "";
        $counter = 0;
        while (!feof($fp)) {
            $c = chop(fgets($fp, 100000));
            $c = ereg_replace("^[ \t]*(#|-- |---*).*", "", $c);
            $command .= $c;
            if (ereg(";\$", $command)) {
                $command = ereg_replace(";\$", "", $command);
                if (ereg("CREATE TABLE ", $command)) {
                    $table_name = ereg_replace(" .*\$", "", eregi_replace("^.*CREATE TABLE ", "", $command));
                    db_query($command);
                    $myerr = mysql_error();
                    if (!empty($myerr)) {
                        $mysql_connection_id = $current_connection;
                        cw_cpanel_install_show_status('create_table', $table_name, false);
                        return false;
                    }
                    $mysql_connection_id = $current_connection;
                    cw_cpanel_install_show_status('create_table', $table_name, true);
                    $mysql_connection_id = $new_connection;
                } else {
                    db_query($command);
                    $myerr = mysql_error();
                    if (!empty($myerr)) {
                        $mysql_connection_id = $current_connection;
                        cw_cpanel_install_show_status('sql_row', $table_name, false);
                        return false;
                    } else {
                        $counter++;
                        if (!($counter % 50)) {
                            echo ".";
                        }
                        flush();
                    }
                }
                $command = "";
                flush();
            }
        }
        fclose($fp);
    }
    $mysql_connection_id = $current_connection;
    return true;
}
开发者ID:CartworksPlatform,项目名称:cartworksplatform,代码行数:67,代码来源:cw.cpanel.php

示例14: cw_patch_execute_sql_query

function cw_patch_execute_sql_query($sql_query, $databases)
{
    global $mysql_connection_id;
    $pieces = array();
    cw_patch_split_sql_file($pieces, $sql_query, PMA_MYSQL_INT_VERSION);
    $pieces_count = count($pieces);
    if ($sql_file != 'none' && $pieces_count > 10) {
        $sql_query_cpy = $sql_query = '';
    } else {
        $sql_query_cpy = implode(";\n", $pieces) . ';';
    }
    // Runs multiple queries
    if (is_array($databases)) {
        $current_connection = $mysql_connection_id;
        foreach ($databases as $params) {
            $ret = @db_connect($params['host'], $params['user'], $params['password']);
            if ($ret) {
                $ret &= db_select_db($params['db']);
            }
            for ($i = 0; $i < $pieces_count; $i++) {
                $a_sql_query = $pieces[$i];
                $result = db_query($a_sql_query);
                if ($result == FALSE) {
                    $my_die = $params['db'] . '@' . $params['host'] . ' ' . $a_sql_query;
                    break;
                }
            }
            if ($result == FALSE) {
                break;
            }
        }
        $mysql_connection_id = $current_connection;
    }
    unset($pieces);
    return $my_die;
}
开发者ID:CartworksPlatform,项目名称:cartworksplatform,代码行数:36,代码来源:cw.patch.php

示例15: namespaces

 function namespaces($fid)
 {
     $namespace_name = array();
     $namespace_location = array();
     global $DBSERVER, $DB, $OWNER, $PW;
     $con = db_connect($DBSERVER, $OWNER, $PW);
     db_select_db($DB, $con);
     $sql = "SELECT * FROM wfs_featuretype_namespace WHERE fkey_featuretype_id = \$1";
     $v = array($fid);
     $t = array("s");
     $res = db_prep_query($sql, $v, $t);
     $cnt = 0;
     while ($row = db_fetch_array($res)) {
         $this->namespace_name[$cnt] = $row["namespace"];
         $this->namespace_location[$cnt] = $row["namespace_location"];
         $cnt++;
     }
 }
开发者ID:bfpi,项目名称:klarschiff-frontend-mit-mapbender,代码行数:18,代码来源:class_wfs_conf.php


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