本文整理汇总了PHP中mysql_selectdb函数的典型用法代码示例。如果您正苦于以下问题:PHP mysql_selectdb函数的具体用法?PHP mysql_selectdb怎么用?PHP mysql_selectdb使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mysql_selectdb函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _fillEmployeeHistoryTable
private function _fillEmployeeHistoryTable($dbName)
{
mysql_selectdb($dbName);
/* Get employee data from `hs_hr_employee` and `hs_hr_job_title` tables */
$query = "SELECT a.`emp_number` , a.`job_title_code` , a.`joined_date` , b.`jobtit_name` FROM hs_hr_employee a, hs_hr_job_title b WHERE a.`job_title_code` IS NOT NULL AND a.`job_title_code` = b.`jobtit_code`";
$result = mysql_query($query);
if (mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_array($result)) {
if (isset($insertSqlSub)) {
$insertSqlSub = $insertSqlSub . ' , ' . '(' . "'" . $row['emp_number'] . "'" . ' , ' . "'" . $row['job_title_code'] . "'" . ' , ' . "'" . $row['jobtit_name'] . "'" . ' , ' . "'" . $row['joined_date'] . "'" . ' ) ';
} else {
$insertSqlSub = '(' . "'" . $row['emp_number'] . "'" . ' , ' . "'" . $row['job_title_code'] . "'" . ' , ' . "'" . $row['jobtit_name'] . "'" . ' , ' . "'" . $row['joined_date'] . "'" . ' ) ';
}
}
/* Insert data to hs_hr_emp_jobtitle_history table */
$insqrtSql = "INSERT INTO hs_hr_emp_jobtitle_history (`emp_number` , `code` , `name` , `start_date`) VALUES {$insertSqlSub}";
if (!mysql_query($insqrtSql)) {
$this->errorArray[] = "Filling Employee History table failed";
return false;
}
return true;
} else {
return true;
}
}
示例2: initialize
private function initialize()
{
$this->_ensureModuleExistance();
/* Initializes link to MySql */
$this->link = mysql_connect("{$this->host}:{$this->port}", $this->user, $this->pass);
if (mysql_error($this->link)) {
throw new WURFL_Storage_Exception("Couldn't link to {$this->host} (" . mysql_error($this->link) . ")");
}
/* Initializes link to database */
$success = mysql_selectdb($this->db, $this->link);
if (!$success) {
throw new WURFL_Storage_Exception("Couldn't change to database {$this->db} (" . mysql_error($this->link) . ")");
}
/* Is Table there? */
$test = mysql_query("SHOW TABLES FROM {$this->db} LIKE '{$this->table}'", $this->link);
if (!is_resource($test)) {
throw new WURFL_Storage_Exception("Couldn't show tables from database {$this->db} (" . mysql_error($this->link) . ")");
}
// create table if it's not there.
if (mysql_num_rows($test) == 0) {
$sql = "CREATE TABLE `{$this->db}`.`{$this->table}` (\r\n\t\t\t\t\t `{$this->keycolumn}` varchar(255) collate latin1_general_ci NOT NULL,\r\n\t\t\t\t\t `{$this->valuecolumn}` mediumblob NOT NULL,\r\n\t\t\t\t\t `ts` timestamp NOT NULL default CURRENT_TIMESTAMP,\r\n\t\t\t\t\t PRIMARY KEY (`{$this->keycolumn}`)\r\n\t\t\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci";
$success = mysql_query($sql, $this->link);
if (!$success) {
throw new WURFL_Storage_Exception("Table {$this->table} missing in {$this->db} (" . mysql_error($this->link) . ")");
}
}
if (is_resource($test)) {
mysql_free_result($test);
}
}
示例3: selectDb
function selectDb($config)
{
if (connectDb($config)) {
return mysql_selectdb($config['db']['dbname']);
}
return false;
}
示例4: SelectDatabase
function SelectDatabase($p_sDatabase)
{
$this->m_bFileRead = false;
if ($this->m_oLink && strlen($p_sDatabase)) {
if (is_dir($p_sDatabase)) {
$this->m_oLink = 0;
$this->m_bFileRead = true;
$this->m_sDatabase = $p_sDatabase;
return true;
} else {
if (mysql_selectdb($p_sDatabase)) {
$this->m_sDatabase = $p_sDatabase;
return true;
} else {
$this->m_oLink = 0;
$this->m_sDatabase = "";
return false;
}
}
} else {
if (is_dir($p_sDatabase)) {
$this->m_oLink = 0;
$this->m_bFileRead = true;
$this->m_sDatabase = $p_sDatabase;
return true;
} else {
$this->m_oLink = 0;
$this->m_sDatabase = "";
return false;
}
}
}
示例5: init
public function init()
{
define('DBPATH', 'localhost');
define('DBUSER', 'root');
define('DBPASS', 'root');
define('DBNAME', 'bdpinos');
// session_start();
global $dbh;
$dbh = mysql_connect(DBPATH, DBUSER, DBPASS);
mysql_selectdb(DBNAME, $dbh);
if ($_GET['action'] == "chatheartbeat") {
chatHeartbeat();
}
if ($_GET['action'] == "sendchat") {
sendChat();
}
if ($_GET['action'] == "closechat") {
closeChat();
}
if ($_GET['action'] == "startchatsession") {
startChatSession();
}
if (!isset($_SESSION['chatHistory'])) {
$_SESSION['chatHistory'] = array();
}
if (!isset($_SESSION['openChatBoxes'])) {
$_SESSION['openChatBoxes'] = array();
}
}
示例6: Global_Init
function Global_Init()
{
//session_start();
Load_Configs();
if (!strnatcasecmp(trim($GLOBALS['db']['type']), "LB")) {
require_once 'inc/dbmodule_LB.php';
}
if (!strnatcasecmp(trim($GLOBALS['db']['type']), "GD")) {
require_once 'inc/dbmodule_GD.php';
}
//echo "GLOBALS: <BR>"; print_r($GLOBALS['db']); echo "<BR>";
$source_db_ok = SQL_DB_OK("source");
if ($source_db_ok['error'] === false) {
$GLOBALS['db']['s_resource'] = @mysql_connect($GLOBALS['db']['s_host'], $GLOBALS['db']['s_user'], $GLOBALS['db']['s_pass']) or die($_SERVER["SCRIPT_FILENAME"] . "Could not connect to Source MySQL Server. : " . mysql_error());
@mysql_selectdb($GLOBALS['db']['s_base']) or die("Could not connect to Source database [" . $GLOBALS['db']['s_base'] . "] : " . mysql_error());
$GLOBALS['db']['x_resource'] = @mysql_connect($GLOBALS['db']['x_host'], $GLOBALS['db']['x_user'], $GLOBALS['db']['x_pass']) or die($_SERVER["SCRIPT_FILENAME"] . "Could not connect to X-Ray MySQL Server. : " . mysql_error());
@mysql_selectdb($GLOBALS['db']['x_base']) or die("Could not connect to X-Ray database [" . $GLOBALS['db']['x_base'] . "] : " . mysql_error());
$GLOBALS['db']['s_link'] = mysqli_connect($GLOBALS['db']['s_host'], $GLOBALS['db']['s_user'], $GLOBALS['db']['s_pass'], $GLOBALS['db']['s_base']) or die($_SERVER["SCRIPT_FILENAME"] . "Could not connect to Source MySQL Server (multilink). : " . mysqli_error($GLOBALS['db']['s_link']));
mysqli_select_db($GLOBALS['db']['s_link'], $GLOBALS['db']['s_base']) or die("Could not connect to Source database (multilink) [" . $GLOBALS['db']['s_base'] . "] : " . mysqli_error($GLOBALS['db']['s_link']));
$GLOBALS['db']['x_link'] = mysqli_connect($GLOBALS['db']['x_host'], $GLOBALS['db']['x_user'], $GLOBALS['db']['x_pass'], $GLOBALS['db']['x_base']) or die($_SERVER["SCRIPT_FILENAME"] . "Could not connect to X-Ray MySQL Server (multilink). : " . mysqli_error($GLOBALS['db']['x_link']));
mysqli_select_db($GLOBALS['db']['x_link'], $GLOBALS['db']['x_base']) or die("Could not connect to X-Ray database (multilink) [" . $GLOBALS['db']['x_base'] . "] : " . mysqli_error($GLOBALS['db']['x_link']));
} else {
$config_error .= $source_db_ok['message'] . "<BR>";
}
// array_key_exists('form', $_POST) && $_POST['form']!="" ? $_GET = $_POST : NULL;
// array_key_exists('force', $_GET) && $_GET['force']!="" ? $_POST = $_GET : NULL;
if (count($_GET) > 0) {
$_POST = $_GET;
}
// if($_POST['form']!=""){$_GET = $_POST;}
// if($_GET['force']!=""){$_POST = $_GET;}
if (!FixOutput_Bool($GLOBALS['config_settings']['settings']['first_setup'], true, false, true)) {
$GLOBALS['worlds'] = Get_Worlds_Enabled();
}
}
示例7: __construct
function __construct()
{
$this->con = mysql_connect("localhost", "wemake_db", "Dsquare@123");
if (!$this->con) {
die('Could not connect: ' . mysql_error());
}
mysql_selectdb("admin", $this->con);
}
示例8: connectDb
function connectDb()
{
global $conn;
$conn = mysql_connect(DB_HOST, DB_USER, DB_PASS) or die("can't connect to mysql=>" . mysql_error());
mysql_selectdb(DB_NAME, $conn);
mysql_query("SET NAMES utf8", $conn);
//set utf8
}
示例9: __construct
function __construct()
{
$this->con = mysql_connect("localhost", "root", "");
if (!$this->con) {
die('Could not connect: ' . mysql_error());
}
mysql_selectdb("wemakesc_wemakescholars", $this->con);
}
示例10: connectDB
function connectDB()
{
$conn = mysql_connect('localhost', 'root', '');
if (!$conn) {
echo "connection failed";
}
mysql_selectdb('softwareProject', $conn);
return $conn;
}
示例11: dbconnect
public function dbconnect()
{
global $db_username;
global $db_password;
global $db_database;
global $db_host;
$conn = mysql_connect($db_host, $db_username, $db_password);
mysql_selectdb($db_database);
}
示例12: connectDB
function connectDB()
{
$conn = mysql_connect('localhost', 'root', '123456');
if (!$conn) {
echo "connection failed";
}
mysql_selectdb('test', $conn);
return $conn;
}
示例13: switchToEcontent
public static function switchToEcontent()
{
global $configArray;
if (!SwitchDatabase::$changedDB) {
if (SwitchDatabase::isVuFindDatabase()) {
mysql_selectdb($configArray['Database']['database_econtent_dbname']);
SwitchDatabase::$changedDB = true;
}
}
}
示例14: __construct
public function __construct()
{
$this->db_host = "localhost";
$this->db_db = "xing_contacts";
$this->db_username = "xxx";
$this->db_password = "xxx";
mysql_connect($this->db_host, $this->db_username, $this->db_password);
mysql_selectdb($this->db_db);
mysql_query("INSERT INTO zugriffe (name) VALUE ('" . $_SESSION['mode'] . "')");
}
示例15: connectToDB
function connectToDB()
{
$userName = "demo";
$password = "test";
$server = "localhost";
$db = mysql_connect($server, $userName, $passwork);
if ($db != false) {
mysql_selectdb("PushNotification");
mysql_set_charset('utf-8');
}
return $db;
}