本文整理匯總了PHP中DBconnect函數的典型用法代碼示例。如果您正苦於以下問題:PHP DBconnect函數的具體用法?PHP DBconnect怎麽用?PHP DBconnect使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了DBconnect函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: setUp
/**
* \brief initialization
*/
protected function setUp()
{
global $PG_CONN;
$sysconfig = dirname(__FILE__) . '/sysconfigDirTest';
if (!is_callable('pg_connect')) {
$this->markTestSkipped("php-psql not found");
}
$PG_CONN = DBconnect($sysconfig);
}
示例2: PrepareSQL
function PrepareSQL()
{
$db = DBconnect();
//if (!$db) die("Oops! Looks like you could not access main database for unknown reasons. Please try again later or contact admin.");
mysql_select_db("tricking_dbMain", $db);
mysql_query("SET NAMES UTF8");
return "tricking_dbMain";
//$MainDBConn;
}
示例3: createOrder
function createOrder($data)
{
$dbcon = DBconnect();
$stmt = $dbcon->prepare("INSERT into tbl_orders (orderFName, orderLName, orderEmail, orderType, orderPlaceDateTime, orderDueDate, paid, baked, readyForPickup, pickedUp) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
$stmt->bind_param("ssssssssss", $data['orderFName'], $data['orderLName'], $data['orderEmail'], $data['orderType'], $data['orderPlaceDateTime'], $data['orderDueDate'], $data['paid'], $data['baked'], $data['readyForPickup'], $data['pickedUp']);
$stmt->execute();
$id = $dbcon->insert_id;
DBdisconnect($dbcon);
echo $id;
}
示例4: setUpDb
/**
* \brief initialization with db
*/
protected function setUpDb()
{
if (!is_callable('pg_connect')) {
$this->markTestSkipped("php-psql not found");
}
global $PG_CONN;
global $DB_COMMAND;
global $sys_conf;
$DB_COMMAND = dirname(dirname(dirname(dirname(__FILE__)))) . "/testing/db/createTestDB.php";
exec($DB_COMMAND, $dbout, $rc);
$sys_conf = $dbout[0];
$PG_CONN = DBconnect($sys_conf);
}
示例5: getserviceslist
function getserviceslist()
{
$con = DBconnect();
$getservice = DBfetchall("SELECT serviceid,shopid,name,price FROM Service", $con);
$Arr = array();
foreach ($getservice as $row) {
$row2 = DBfetchone("select name,pic,latitude,longtitude from Shop where shopid=" . $row["shopid"] . ";", $con);
$a = array("serviceid" => $row["serviceid"], "shopname" => $row2["name"], "servicename" => $row["name"], "price" => $row["price"], "pic" => $row2["pic"], "latitude" => $row2["latitude"], "longtitude" => $row2["longtitude"]);
//var_dump($row2);
array_push($Arr, $a);
}
echo json_encode($Arr);
}
示例6: setUp
protected function setUp()
{
global $PG_CONN;
global $DB_COMMAND;
global $DB_NAME;
print "Starting unit test for common-pkg.php\n";
$DB_COMMAND = "../../../testing/db/createTestDB.php";
exec($DB_COMMAND, $dbout, $rc);
preg_match("/(\\d+)/", $dbout[0], $matches);
$test_name = $matches[1];
$db_conf = $dbout[0];
$DB_NAME = "fosstest" . $test_name;
#$sysconfig = './sysconfigDirTest';
$PG_CONN = DBconnect($db_conf);
}
示例7: setUp
protected function setUp()
{
if (!is_callable('pg_connect')) {
$this->markTestSkipped("php-psql not found");
}
global $PG_CONN;
global $DB_COMMAND;
global $DB_NAME;
print "Starting unit test for common-pkg.php\n";
$DB_COMMAND = dirname(dirname(dirname(dirname(__FILE__)))) . "/testing/db/createTestDB.php";
exec($DB_COMMAND, $dbout, $rc);
preg_match("/(\\d+)/", $dbout[0], $matches);
$test_name = $matches[1];
$db_conf = $dbout[0];
$DB_NAME = "fosstest" . $test_name;
#$sysconfig = './sysconfigDirTest';
$PG_CONN = DBconnect($db_conf);
}
示例8: getCountryCode
function getCountryCode()
{
$ip = getIp();
// debug:
// $ip = "193.51.208.14"; // French IP
// $ip = "71.164.115.181"; // US IP
$location = null;
if ($ip) {
// db credentials, see db.php.example
require 'db.php';
DBconnect($server, $username, $password, $database);
$location = ipRoughLocate($ip);
}
if (!$location || !$location["countryCode"] || $location["countryName"] == "(Unknown Country?)") {
return "US";
} else {
return $location["countryCode"];
}
}
示例9: __construct
function __construct($dbName = null, $sysConf = null)
{
$dbName = strtolower($dbName);
$testDbFactory = new \TestDbFactory();
$this->sys_conf = $sysConf;
if (empty($this->sys_conf)) {
$this->sys_conf = $testDbFactory->setupTestDb($dbName);
$dbName = $testDbFactory->getDbName($this->sys_conf);
}
$this->dbName = $dbName;
require_once dirname(dirname(__FILE__)) . '/common-db.php';
$this->connection = DBconnect($this->sys_conf);
require dirname(dirname(__FILE__)) . '/common-container.php';
global $container;
$logger = new Logger('default');
// $container->get('logger');
$this->logFileName = dirname(dirname(dirname(dirname(dirname(__FILE__))))) . 'db.pg.log';
$logger->pushHandler(new StreamHandler($this->logFileName, Logger::DEBUG));
$container->get('db.manager')->setDriver(new Postgres($this->connection));
$this->dbManager = $container->get('db.manager');
$this->dbManager->queryOnce("DEALLOCATE ALL");
$this->dropAllTables();
$this->dropAllSequences();
}
示例10: Output
/**
* \brief Generate output.
*/
function Output()
{
global $PG_CONN;
global $Plugins;
// make sure there is a db connection since I've pierced the core-db abstraction
if (!$PG_CONN) {
DBconnect();
if (!$PG_CONN) {
echo "NO DB connection";
}
}
if ($this->State != PLUGIN_STATE_READY) {
return;
}
$V = "";
// tmp $this->popmd5();
switch ($this->OutputType) {
case "XML":
break;
case "Text":
break;
case "HTML":
// micro menus
$V .= menu_to_1html(menu_find($this->Name, $MenuDepth), 0);
//debugprint($_REQUEST, "_REQUEST");
$errorstr = "License not added";
// update the db
if (@$_POST["updateit"]) {
$resultstr = $this->Updatedb($_POST);
$V .= $resultstr;
if (strstr($resultstr, $errorstr)) {
$V .= $this->Updatefm(0);
} else {
$V .= $this->Inputfm();
}
break;
}
if (@$_REQUEST['add'] == 'y') {
$V .= $this->Updatefm(0);
break;
}
// Add new rec to db
if (@$_POST["addit"]) {
$resultstr = $this->Adddb($_POST);
$V .= $resultstr;
if (strstr($resultstr, $errorstr)) {
$V .= $this->Updatefm(0);
} else {
$V .= $this->Inputfm();
}
break;
}
// bring up the update form
$rf_pk = @$_REQUEST['rf_pk'];
if ($rf_pk) {
$V .= $this->Updatefm($rf_pk);
break;
}
$V .= $this->Inputfm();
if (@$_POST["req_shortname"]) {
$V .= $this->LicenseList($_POST["req_shortname"], $_POST["req_marydone"]);
}
break;
default:
break;
}
if (!$this->OutputToStdout) {
return $V;
}
print $V;
return;
}
示例11: DBInsert
function DBInsert($sql)
{
DBconnect();
return mysql_query($sql);
}
示例12: getRights
public static function getRights()
{
try {
// Effectue une connexion à la DB.
$pdo = DBconnect();
// Prépare la requête.
$stmt = $pdo->prepare("SELECT * FROM t_right ORDER BY id");
// Execute la requête.
if ($stmt->execute()) {
// Set le type de traitement de la réponse.
$stmt->setFetchMode(PDO::FETCH_CLASS, 'Right');
// Récupère le résultat de la requête.
if ($r = $stmt->fetchAll()) {
return $r;
}
}
// Retourne un objet null si l'utilisateur n'a pas été récuperé.
return null;
} catch (Exception $e) {
// Retourne un objet null si une erreur c'est produite.
return null;
} finally {
// Ferme le traitement.
$stmt->closeCursor();
// Ferme la connexion vers la base de donnée.
$pdo = null;
}
}
示例13: CheckConfigurationFile
function CheckConfigurationFile()
{
global $DB, $ZBX_SERVER, $ZBX_SERVER_PORT;
if (!empty($DB)) {
$old_DB = true;
$old_DB_TYPE = $DB['TYPE'];
$old_DB_SERVER = $DB['SERVER'];
$old_DB_PORT = $DB['PORT'];
$old_DB_DATABASE = $DB['DATABASE'];
$old_DB_USER = $DB['USER'];
$old_DB_PASSWORD = $DB['PASSWORD'];
$old_ZBX_SERVER = $ZBX_SERVER;
$old_ZBX_SERVER_PORT = $ZBX_SERVER_PORT;
}
$error = null;
$error_msg = null;
global $ZBX_CONFIGURATION_FILE;
if (file_exists($ZBX_CONFIGURATION_FILE)) {
include $ZBX_CONFIGURATION_FILE;
if (isset($DB['TYPE']) && isset($DB['SERVER']) && isset($DB['DATABASE']) && isset($DB['USER']) && isset($DB['PASSWORD']) && isset($ZBX_SERVER) && isset($ZBX_SERVER_PORT) && isset($IMAGE_FORMAT_DEFAULT) && $DB['TYPE'] == $this->getConfig('DB_TYPE', null) && $DB['SERVER'] == $this->getConfig('DB_SERVER', null) && $DB['PORT'] == $this->getConfig('DB_PORT', null) && $DB['DATABASE'] == $this->getConfig('DB_DATABASE', null) && $DB['USER'] == $this->getConfig('DB_USER', null) && $DB['PASSWORD'] == $this->getConfig('DB_PASSWORD', null)) {
if (!DBconnect($error_msg)) {
$error_msg = 'Can not connect to database';
}
} else {
$error_msg = 'Incorrect configuration file[' . $ZBX_CONFIGURATION_FILE . ']';
}
DBclose();
} else {
$error = 'Missing configuration file[' . $ZBX_CONFIGURATION_FILE . ']';
}
if (isset($error_msg)) {
error($error_msg);
}
/* restore connection */
global $DB;
if (isset($old_DB)) {
$DB['TYPE'] = $old_DB_TYPE;
$DB['SERVER'] = $old_DB_SERVER;
$DB['PORT'] = $old_DB_PORT;
$DB['DATABASE'] = $old_DB_DATABASE;
$DB['USER'] = $old_DB_USER;
$DB['PASSWORD'] = $old_DB_PASSWORD;
$ZBX_SERVER = $old_ZBX_SERVER;
$ZBX_SERVER_PORT = $old_ZBX_SERVER_PORT;
}
DBconnect($error2);
return !isset($error) && !isset($error_msg);
}
示例14: RDride
?>
</TH>
<TH class="tbLogHeader">Location</TH>
<TH class="tbLogHeader">Dist<br><?php
echo $units->distanceString();
?>
</TH>
<TH class="tbLogHeader">Time</TH>
<TH class="tbLogHeader">Avg<br><?php
echo $units->velocityString();
?>
</TH>
<TH class="tbLogHeader">Effort</TH>
</TR>
<?php
$rides = new RDride(DBconnect(), $units);
$result = $rides->queryRides($currentQuery->getWhereStatement(), $start, $num + 1);
$totalTime = 0;
$totalDist = 0;
$numRides = 0;
//Not really num rides, used to see if more data is available.
while ($rides->parseNextRow($result)) {
$numRides++;
if ($numRides > $num) {
break;
}
echo "<TR>";
echo "<TD class=\"tbLogBody\">" . "<a href=\"showRide.php";
$tgetvars = $getVars;
$tgetvars["rideID"] = $rides->f_rideID;
echo encodeGet($tgetvars) . "\">" . $rides->getDatePart() . " " . $rides->getTimePart() . "</a> " . "<img width='10' height='16' src=\"" . getImgForTemp($rides->f_temperature, $units) . "\">" . "<img width='25' height='16' src=\"s" . $rides->f_sky . ".png\">" . "<img width='16' height='16' src=\"w" . $rides->f_wind . ".png\">" . "</TD>";
示例15: PostInitialize
/**
* \brief This is where the magic for
* Authentication happens.
*/
function PostInitialize()
{
global $PG_CONN;
global $SysConf;
if (siteminder_check() == -1) {
return;
}
$UID = siteminder_check();
global $container;
/** @var Session $session */
$session = $container->get('session');
$session->setName('Login');
$session->start();
if (array_key_exists(Auth::USER_ID, $_SESSION)) {
$SysConf['auth'][Auth::USER_ID] = $_SESSION[Auth::USER_ID];
}
$Now = time();
if (!empty($_SESSION['time'])) {
/* Logins older than 60 secs/min * 480 min = 8 hr are auto-logout */
if (@$_SESSION['time'] + 60 * 480 < $Now) {
$_SESSION['User'] = NULL;
$_SESSION[Auth::USER_ID] = NULL;
$_SESSION[Auth::USER_LEVEL] = NULL;
$SysConf['auth'][Auth::USER_ID] = NULL;
$_SESSION['UserEmail'] = NULL;
$_SESSION['Folder'] = NULL;
$_SESSION['UiPref'] = NULL;
/* TODO: need to clear SiteMinder session */
}
}
/* check db connection */
if (!$PG_CONN) {
DBconnect();
if (!$PG_CONN) {
echo "NO DB connection";
}
}
/* Enable or disable plugins based on login status */
$Level = PLUGIN_DB_NONE;
if (@$_SESSION['User']) {
//TODO: also need to check SiteMinder session
/* If you are logged in, then the default level is "Download". */
if ("X" . $_SESSION[Auth::USER_LEVEL] == "X") {
$Level = PLUGIN_DB_WRITE;
} else {
$Level = $_SESSION[Auth::USER_LEVEL];
}
/* Recheck the user in case he is suddenly blocked or changed. */
if (empty($_SESSION['time_check'])) {
$_SESSION['time_check'] = time() + 480 * 60;
}
if (time() >= @$_SESSION['time_check']) {
$sql = "SELECT * FROM users WHERE user_pk='" . @$_SESSION['UserId'] . "';";
$result = pg_query($PG_CONN, $sql);
DBCheckResult($result, $sql, __FILE__, __LINE__);
$R = pg_fetch_assoc($result);
pg_free_result($result);
$_SESSION['User'] = $R['user_name'];
$_SESSION['Folder'] = $R['root_folder_fk'];
$_SESSION[Auth::USER_LEVEL] = $R['user_perm'];
$_SESSION['UserEmail'] = $R['user_email'];
$_SESSION['UserEnote'] = $R['email_notify'];
if (empty($R['ui_preference'])) {
$_SESSION['UiPref'] = 'simple';
} else {
$_SESSION['UiPref'] = $R['ui_preference'];
}
$Level = $_SESSION[Auth::USER_LEVEL];
}
} else {
$this->CheckUser($UID);
$Level = $_SESSION[Auth::USER_LEVEL];
}
/* Disable all plugins with >= $Level access */
plugin_disable($Level);
$this->State = PLUGIN_STATE_READY;
}