本文整理汇总了PHP中database_connect函数的典型用法代码示例。如果您正苦于以下问题:PHP database_connect函数的具体用法?PHP database_connect怎么用?PHP database_connect使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了database_connect函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: duplicate_template
/**
*
* Function create folder loop
* This function creates folders needed when duplicating a template
* @param string $folder_name_id - the id of the new template
* @param number $id_to_copy - the id of the old template
* @param string $tutorial_id_from_post - The name of this tutorial type i.e Nottingham
* @version 1.0
* @author Patrick Lockley
*/
function duplicate_template($folder_name_id, $id_to_copy, $tutorial_id_from_post)
{
global $dir_path, $new_path, $temp_dir_path, $temp_new_path, $xerte_toolkits_site;
$database_id = database_connect("file_library database connect success", "file_library database connect fail");
$query_for_framework = "select template_framework from " . $xerte_toolkits_site->database_table_prefix . "originaltemplatesdetails where template_name =\"" . $tutorial_id_from_post . "\"";
$query_for_framework_response = mysql_query($query_for_framework);
$row_framework = mysql_fetch_array($query_for_framework_response);
$dir_path = $xerte_toolkits_site->users_file_area_full . $id_to_copy . "-" . $_SESSION['toolkits_logon_username'] . "-" . $tutorial_id_from_post . "/";
/*
* Get the id of the folder we are looking to copy into
*/
$new_path = $xerte_toolkits_site->users_file_area_full . $folder_name_id . "-" . $_SESSION['toolkits_logon_username'] . "-" . $tutorial_id_from_post . "/";
$path = $xerte_toolkits_site->users_file_area_full . $folder_name_id . "-" . $_SESSION['toolkits_logon_username'] . "-" . $tutorial_id_from_post . "/";
if (mkdir($path)) {
if (@chmod($path, 0777)) {
$d = opendir($dir_path);
if (create_folder_loop($d, -1)) {
if (file_exists($new_path = $xerte_toolkits_site->users_file_area_full . $folder_name_id . "-" . $_SESSION['toolkits_logon_username'] . "-" . $tutorial_id_from_post . "/lockfile.txt")) {
unlink($new_path = $xerte_toolkits_site->users_file_area_full . $folder_name_id . "-" . $_SESSION['toolkits_logon_username'] . "-" . $tutorial_id_from_post . "/lockfile.txt");
}
return true;
} else {
return false;
}
} else {
receive_message($_SESSION['toolkits_logon_username'], "FILE_SYSTEM", "MAJOR", "Failed to set rights on parent folder for template", "Failed to set rights on parent folder " . $path);
return false;
}
} else {
receive_message($_SESSION['toolkits_logon_username'], "FILE_SYSTEM", "CRITICAL", "Failed to create parent folder for template", "Failed to create parent folder " . $path);
return false;
}
}
示例2: search_info_GO_terms
function search_info_GO_terms($GO_terms)
{
if (!database_connect()) {
return "DB_CONNECT_FAILURE";
}
if (empty($GO_terms)) {
return array();
}
# Set up parameters
$search = "*";
$table = $GLOBALS['TABLE_GO_NAMES'];
#Build the where statement
$where = "0 = 1";
if (!empty($GO_terms)) {
$where = "pid IN " . build_IN_LIST($GO_terms);
}
#Do the search
$result = database_select_distinct_search($search, $table, $where);
# Throw the results into an array
$resultArray = array();
while ($row = mysql_fetch_assoc($result)) {
$row["searchType"] = "GO";
array_push($resultArray, $row);
}
#database dc
database_disconnect();
#return the results array
if (count($resultArray) == 0) {
return "EMPTY";
}
# Is the array empty?
return $resultArray;
}
示例3: outputStudents
function outputStudents()
{
$conn = database_connect();
//$conn = mysqli_connect(DATABASE_HOST, DATABASE_USER, DATABASE_PASS, DATABASE_HOME);
$query = "SELECT seatNumber,name,md5hash FROM students";
$result = mysqli_query($conn, $query);
if (mysqli_errno($conn)) {
echo mysqli_error($conn);
}
echo '<pre>';
while ($row = mysqli_fetch_array($result)) {
// print_r($row);
if ($row['seatNumber'] == $_SESSION['runCounter']) {
echo "CURRENT:\t";
} else {
if ($row['seatNumber'] % 2 == 1) {
echo "ODD:\t";
} else {
echo "EVEN:\t";
}
}
echo $row['seatNumber'] . "\t" . $row['name'] . '<br>';
}
echo '</pre>';
$numRows = mysqli_num_rows($result);
if ($_SESSION['runCounter'] > $numRows) {
$_SESSION['runCounter'] = 1;
}
database_disconnect($conn);
}
示例4: move_file
/**
*
* Function move file
* This function is used to move files and folders
* @param array $files_to_move = an array of files and folders to move
* @param string $destination = Name of the new folder
* @version 1.0
* @author Patrick Lockley
*/
function move_file($files_to_move, $destination)
{
global $xerte_toolkits_site;
$mysql_id = database_connect("Move file database connect success", "Move file database connect failure");
$new_files_array = explode(",", $files_to_move);
/*
* Files array can be complicated, and this thread can lock the system, so limit max files to 50
*/
if (count($new_files_array) != 0 && count($new_files_array) <= 50) {
/*
* check their is a destination
*/
if ($destination != "") {
for ($x = 0; $x != count($new_files_array); $x++) {
// check there are files
if ($new_files_array[$x] != "") {
if ($new_files_array[$x + 1] == "file") {
if ($new_files_array[$x + 2] == "folder_workspace") {
$parent = get_user_root_folder();
}
if ($destination == "folder_workspace") {
$destination = get_user_root_folder();
}
if ($destination == "recyclebin") {
$destination = get_recycle_bin();
}
/*
* Move files in the database
*/
$query_file = "UPDATE " . $xerte_toolkits_site->database_table_prefix . "templaterights SET folder = \"" . $destination . "\" where (template_id=\"" . $new_files_array[$x] . "\" AND user_id =\"" . $_SESSION['toolkits_logon_id'] . "\")";
if (mysql_query($query_file)) {
receive_message($_SESSION['toolkits_logon_username'], "USER", "SUCCESS", "File " . $new_files_array[$x] . " moved into " . $destination . " for " . $_SESSION['toolkits_logon_username'], "File " . $new_files_array[$x] . " moved into " . $destination . " for " . $_SESSION['toolkits_logon_username']);
} else {
receive_message($_SESSION['toolkits_logon_username'], "USER", "SUCCESS", "File " . $new_files_array[$x] . " failed to move into " . $destination . " for " . $_SESSION['toolkits_logon_username'], "File " . $new_files_array[$x] . " failed to move into " . $destination . " for " . $_SESSION['toolkits_logon_username']);
}
} else {
/*
* destination is the root folder
*/
if ($destination == "folder_workspace") {
$destination = get_user_root_folder();
}
$query_folder = "UPDATE " . $xerte_toolkits_site->database_table_prefix . "folderdetails SET folder_parent = \"" . $destination . "\" where (folder_id=\"" . $new_files_array[$x] . "\")";
if (mysql_query($query_folder)) {
receive_message($_SESSION['toolkits_logon_username'], "USER", "SUCCESS", "Folder " . $new_files_array[$x] . " moved into " . $destination . " for " . $_SESSION['toolkits_logon_username'], "File " . $new_files_array[$x] . " moved into " . $destination . " for " . $_SESSION['toolkits_logon_username']);
} else {
receive_message($_SESSION['toolkits_logon_username'], "USER", "SUCCESS", "File " . $new_files_array[$x] . " failed to move into " . $destination . " for " . $_SESSION['toolkits_logon_username'], "Folder " . $new_files_array[$x] . " failed to move into " . $destination . " for " . $_SESSION['toolkits_logon_username']);
}
}
$x += 2;
}
}
}
}
mysql_close($mysql_id);
}
示例5: licence_list
function licence_list()
{
global $xerte_toolkits_site;
$database_id = database_connect("licence list connected", "licence list failed");
echo "<p>" . MANAGEMENT_LIBRARY_NEW_LICENCE . "</p>";
echo "<p>" . MANAGEMENT_LIBRARY_NEW_LICENCE_DETAILS . "<form><textarea cols=\"100\" rows=\"2\" id=\"newlicense\">" . MANAGEMENT_LIBRARY_NEW_LICENCE_NAME . "</textarea></form></p>";
echo "<p><form action=\"javascript:new_license();\"><button type=\"submit\" class=\"xerte_button\" ><i class=\"fa fa-plus-circle\"></i> " . MANAGEMENT_LIBRARY_NEW_LABEL . "</button></form></p>";
echo "<p>" . MANAGEMENT_LIBRARY_MANAGE_LICENCES . "</p>";
$query = "select * from " . $xerte_toolkits_site->database_table_prefix . "syndicationlicenses";
$query_response = db_query($query);
foreach ($query_response as $row) {
echo "<p>" . $row['license_name'] . " - <button type=\"button\" class=\"xerte_button\" onclick=\"javascript:remove_licenses('" . $row['license_id'] . "')\"><i class=\"fa fa-minus-circle\"></i> " . MANAGEMENT_LIBRARY_REMOVE . " </button></p>";
}
}
示例6: db_query
/**
* Poorman's prepared statement emulation. Does not cope with named parameters - only ?'s.
* @param string $sql - e.g. "SELECT * FROM users WHERE name = ? OR name = ?"
* @param array $params - e.g. array('bob', "david's");
* @return mysql resultset.
*/
function db_query($sql, $params = array())
{
$connection = database_connect('db_query ok', 'db_query fail');
foreach ($params as $key => $value) {
if (isset($value)) {
if (get_magic_quotes_gpc()) {
$value = stripslashes($value);
}
$value = "'" . mysql_real_escape_string($value) . "'";
} else {
$value = 'NULL';
}
// overwrite the $params data with the santised stuff.
$params[$key] = $value;
}
// following code taken from php.net/mysql_query - axiak at mit dot edu - 24th october 2006
$curpos = 0;
$curph = count($params) - 1;
// start at the end of the string and replace things backwards; this avoids us replacing a replacement
for ($i = strlen($sql) - 1; $i > 0; $i--) {
if ($sql[$i] !== '?') {
continue;
}
if ($curph < 0) {
$sql = substr_replace($sql, 'NULL', $i, 1);
} else {
$sql = substr_replace($sql, $params[$curph], $i, 1);
}
$curph--;
}
_debug("Running : {$sql}", 1);
$result = mysql_query($sql, $connection);
if (!$result) {
_debug("Failed to execute query : {$sql} : " . mysql_error());
return false;
}
if (preg_match("/^select/i", $sql)) {
$rows = array();
while ($row = mysql_fetch_assoc($result)) {
$rows[] = $row;
}
return $rows;
}
return $result;
}
示例7: init
public static function init()
{
global $config;
require_once "core/config.php";
// Libraries
$libs = scandir("core/lib");
foreach ($libs as $file) {
if (pathinfo($file, PATHINFO_EXTENSION) == "php") {
require_once "core/lib/{$file}";
}
}
// Classes
$classes = scandir("core/classes");
foreach ($classes as $file) {
if (pathinfo($file, PATHINFO_EXTENSION) == "php") {
require_once "core/classes/{$file}";
}
}
database_connect();
Site::init();
global $site;
}
示例8: search_infoTable
function search_infoTable($chemicals)
{
if (!database_connect()) {
return "DB_CONNECT_FAILURE";
}
if (empty($chemicals)) {
return "NO_SEARCH";
}
# Set up parameters of a basic chemicalSGA search
$search = "chemicalConditions.*, chemicals.structure_pic";
$table = "chemicalConditions, chemicals";
#Build the where statement
$andQueryArray = array();
if (!empty($chemicals)) {
array_push($andQueryArray, "chemicalConditions.chemical_name IN " . build_IN_LIST($chemicals));
}
//array_push($andQueryArray, build_OR($chemicals, "chemicalConditions.chemical_name='", "'"));}
array_push($andQueryArray, 'chemicalConditions.chemical_name = chemicals.name');
$where = build_AND($andQueryArray);
//echo($where);
//print $where;
#Do the search
$result = database_select_distinct_search($search, $table, $where);
# Throw the results into an array
$resultArray = array();
while ($row = mysql_fetch_assoc($result)) {
array_push($resultArray, $row);
}
#database dc
database_disconnect();
#return the results array
if (count($resultArray) == 0) {
return "EMPTY";
}
# Is the array empty?
return $resultArray;
}
示例9: _load_language_file
/**
*
* duplicate_template, allows the template to be duplicated
*
* @author Patrick Lockley
* @version 1.0
* @copyright Copyright (c) 2008,2009 University of Nottingham
* @package
*/
require_once "../../../config.php";
include "../user_library.php";
include "../template_library.php";
include "../template_status.php";
_load_language_file("/website_code/php/templates/duplicate_template.inc");
$database_connect_id = database_connect("new_template database connect success", "new_template database connect fail");
/*
* get the root folder for this user
*/
if (is_numeric($_POST['template_id'])) {
if (is_user_creator(mysql_real_escape_string($_POST['template_id']))) {
if ($_POST['folder_id'] == "workspace") {
$folder_id = get_user_root_folder();
} else {
$folder_id = $_POST['folder_id'];
}
/*
* get the maximum id number from templates, as the id for this template
*/
$maximum_template_id = get_maximum_template_number();
//$query_for_root_folder = "select folder_id from " . $xerte_toolkits_site->database_table_prefix . "folderdetails where login_id = '" . $_SESSION['toolkits_logon_id'] . "' and folder_parent='0'";
示例10: trigger_error
trigger_error("You are running an unsupported version of PHP/XerteOnlineToolkits. Please run PHP v5.1 or above");
}
require_once dirname(__FILE__) . '/functions.php';
require_once dirname(__FILE__) . '/library/autoloader.php';
if (!isset($xerte_toolkits_site)) {
// create new generic object to hold all our config stuff in....
$xerte_toolkits_site = new StdClass();
/**
* Access the database to get the variables
*/
if (!is_file(dirname(__FILE__) . '/database.php')) {
header("Location: " . $_SERVER['REQUEST_URI'] . "setup/");
}
require_once dirname(__FILE__) . '/database.php';
require_once dirname(__FILE__) . '/website_code/php/database_library.php';
if (!database_connect("", "")) {
die("database.php isn't correctly configured; cannot connect to database; have you run /setup?");
}
$row = db_query_one("SELECT * FROM {$xerte_toolkits_site->database_table_prefix}sitedetails");
/**
* Access the database to get the variables
* @version 1.0
* @author Patrick Lockley
* @copyright 2008,2009 University of Nottingham
*/
/**
* Include any script that is used for configuration - for moodle this might be e.g. '/xampp/htdocs/moodle/config.php'.
*/
if ($row['integration_config_path'] != "") {
require_once $row['integration_config_path'];
}
示例11: die
/**
*
* template close, code that runs when an editor window is closed to remove the lock file
*
* @author Patrick Lockley
* @version 1.0
* @package
*/
require_once '../../../config.php';
if (empty($_SESSION) || !isset($_SESSION['toolkits_logon_id'])) {
die("Session expired; please login again.");
}
_load_language_file("/website_code/php/versioncontrol/template_close.inc");
require '../template_status.php';
$temp_array = explode("-", $_POST['file_path']);
database_connect("template close success", "template close fail");
if (file_exists($xerte_toolkits_site->users_file_area_full . $_POST['file_path'] . "lockfile.txt")) {
/*
* Code to delete the lock file
*/
$lock_file_data = file_get_contents($xerte_toolkits_site->users_file_area_full . $temp_array[0] . "-" . $temp_array[1] . "-" . $temp_array[2] . "/lockfile.txt");
$temp = explode("*", $lock_file_data);
$lock_file_creator = $temp[0];
$template_id = explode("-", $_POST['file_path']);
$row_template_name = db_query_one("Select template_name from {$xerte_toolkits_site->database_table_prefix}templatedetails WHERE template_id = ?", array($template_id[0]));
$user_list = $temp[1];
$users = explode(" ", $user_list);
/*
* Email users in the lock file
*/
for ($x = 0; $x != count($users) - 1; $x++) {
示例12: database_connect
<?php
include "config/config.php";
include "functions/database.fn.php";
$link = database_connect($db);
$sql = 'SELECT * FROM poney WHERE id=' . $_GET['id'];
$result = mysql_query($sql);
if (!$result) {
die('erreur dans la requete : ' . mysql_error());
}
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
include "templates/html-opening.php";
$rate = $row["rate"];
echo '<img src="images/' . $row["image"] . '" alt="poney" class="imgprofile" /><br />';
if ($rate == 1) {
echo '<img src="images/1star.gif" alt="stars" class="starsprofile" />';
} elseif ($rate == 2) {
echo '<img src="images/2stars.gif" alt="stars" class="starsprofile" />';
} elseif ($rate == 3) {
echo '<img src="images/3stars.gif" alt="stars" class="starsprofile" />';
} elseif ($rate == 4) {
echo '<img src="images/4stars.gif" alt="stars" class="starsprofile" />';
} elseif ($rate == 5) {
echo '<img src="images/5stars.gif" alt="stars" class="starsprofile" />';
}
echo '<div id="details">';
echo '<h3>' . $row["nom"] . '</h3>';
echo '<ul>';
echo '<li>Age: ' . $row["age"] . '</li>';
echo '<li>Sex: ' . $row["sex"] . '</li>';
echo '<li>Color: ' . $row["color"] . '</li>';
示例13: sendError
$_SESSION['user_id'] = $user['userID'];
$_SESSION['user'] = $_POST['user'];
$_SESSION['permissions'] = $user['permissions'];
$_SESSION['auth'] = true;
}
} else {
sendError('Bad username or password.');
}
}
$dbHandle = null;
}
/**
* If user is authorized, read settings and create user-specific temp dirs.
*/
if (isset($_SESSION['auth']) && isset($_POST['form'])) {
database_connect(IL_USER_DATABASE_PATH, 'users');
$user_id_q = $dbHandle->quote($_SESSION['user_id']);
// Session management.
if ($ini_array['autosign'] == 0) {
$session_id_q = $dbHandle->quote(session_id());
// Save this signin in db.
$dbHandle->exec("DELETE FROM logins" . " WHERE sessionID={$session_id_q} AND userID={$user_id_q}");
$dbHandle->exec("INSERT INTO logins (userID, sessionID, logintime)" . " VALUES ({$user_id_q}, {$session_id_q},'" . time() . "')");
// Delete all other signed in devices for this user.
$result = $dbHandle->query("SELECT sessionID FROM logins" . " WHERE sessionID!={$session_id_q} AND userID={$user_id_q}");
while ($oldsession = $result->fetch(PDO::FETCH_ASSOC)) {
// Delete session file.
@unlink(IL_TEMP_PATH . DIRECTORY_SEPARATOR . 'I,_Librarian_sessions' . DIRECTORY_SEPARATOR . 'sess_' . $oldsession['sessionID']);
// Clen session temp dir.
$clean_files = array();
$clean_files = glob(IL_TEMP_PATH . DIRECTORY_SEPARATOR . 'lib_' . $oldsession['sessionID'] . DIRECTORY_SEPARATOR . '*', GLOB_NOSORT);
示例14: getSettingsPage
protected function getSettingsPage()
{
if ($this->login->getUsername() == $this->settings->admin_username && $this->login->getPassword() == $this->settings->admin_password) {
$_SESSION['toolkits_logon_id'] = "site_administrator";
$mysql_id = database_connect("management.php database connect success", "management.php database connect fail");
$this->page['isAdmin'] = true;
} else {
$this->getLoginPage();
return;
}
return $this->pageDisplayHelper();
}
示例15: database_connect
<?php
include_once 'data.php';
if (isset($_SESSION['auth']) && isset($_SESSION['permissions']) && ($_SESSION['permissions'] == 'A' || $_SESSION['permissions'] == 'U')) {
include_once 'functions.php';
database_connect(IL_DATABASE_PATH, 'library');
if (!empty($_GET['details'])) {
$dbHandle->sqliteCreateFunction('levenshtein', 'sqlite_levenshtein', 2);
if (!empty($_GET['journal'])) {
$journal_query = $dbHandle->quote($_GET['journal']);
$result = $dbHandle->query("SELECT journal,count(*) FROM library WHERE levenshtein(upper(journal), upper({$journal_query})) < 4 GROUP BY journal");
print '<b>Possible variants:</b>';
while ($jour = $result->fetch(PDO::FETCH_ASSOC)) {
if (!empty($jour['journal'])) {
print '<br><button class="rename-journal-button" style="margin:1px"><i class="fa fa-pencil"></i></button> ';
print '<span>' . htmlspecialchars($jour['journal']) . '</span> (' . $jour['count(*)'] . ')';
}
}
$result = null;
$result = $dbHandle->query("SELECT secondary_title,count(*) FROM library WHERE journal={$journal_query} GROUP BY secondary_title");
print '<br><b>Associated secondary titles:</b>';
while ($jour = $result->fetch(PDO::FETCH_ASSOC)) {
if (!empty($jour['secondary_title'])) {
print '<br><button class="rename-secondary-title-button" style="margin:1px"><i class="fa fa-pencil"></i></button> ';
print '<span>' . htmlspecialchars($jour['secondary_title']) . '</span> (' . $jour['count(*)'] . ')';
}
}
}
if (!empty($_GET['secondary_title'])) {
$journal_query = $dbHandle->quote($_GET['secondary_title']);
$result = $dbHandle->query("SELECT secondary_title,count(*) FROM library WHERE levenshtein(upper(secondary_title), upper({$journal_query})) < 4 GROUP BY secondary_title");