本文整理汇总了PHP中dbconnect函数的典型用法代码示例。如果您正苦于以下问题:PHP dbconnect函数的具体用法?PHP dbconnect怎么用?PHP dbconnect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dbconnect函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create_table
function create_table($majorcode, $semester, $year)
{
$dbc = dbconnect('local');
$req_database = $majorcode . "_" . $semester . "_" . $year . "_req_courses";
$prereq_database = $majorcode . "_" . $semester . "_" . $year . "_prereq_courses";
$foundation_database = $majorcode . "_" . $semester . "_" . $year . "_foundation_courses";
$query1 = "CREATE TABLE `{$foundation_database}` (\r\n `course_id` int(11) NOT NULL AUTO_INCREMENT,\r\n `course_code` varchar(45) NOT NULL,\r\n `credit` int(11) NOT NULL,\r\n `course_name` varchar(45) NOT NULL,\r\n `course_ava` int(11) NOT NULL DEFAULT '0',\r\n `course_set` int(11) DEFAULT NULL,\r\n `is_deleted` tinyint(1) NOT NULL DEFAULT '0',\r\n `date_created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\r\n `last_updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\r\n PRIMARY KEY (`course_id`)\r\n) ";
$query2 = "CREATE TABLE `{$prereq_database}` (\r\n `course_id` int(11) NOT NULL AUTO_INCREMENT,\r\n `req_course_code` varchar(45) NOT NULL,\r\n `course_code` varchar(45) NOT NULL,\r\n `course_name` varchar(45) NOT NULL,\r\n `credit` int(11) NOT NULL,\r\n `course_set` int(11) NOT NULL,\r\n `course_ava` int(11) NOT NULL DEFAULT '0',\r\n `is_deleted` tinyint(1) NOT NULL DEFAULT '0',\r\n `date_created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\r\n `last_updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\r\n PRIMARY KEY (`course_id`)\r\n) ";
$query3 = "CREATE TABLE `{$req_database}` (\r\n `course_id` int(11) NOT NULL AUTO_INCREMENT,\r\n `course_code` varchar(45) NOT NULL,\r\n `credit` int(11) NOT NULL,\r\n `course_name` varchar(45) NOT NULL,\r\n `course_set` int(11) DEFAULT '0',\r\n `course_ava` int(11) NOT NULL DEFAULT '0',\r\n `is_deleted` tinyint(1) NOT NULL DEFAULT '0',\r\n `date_created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\r\n `last_updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\r\n PRIMARY KEY (`course_id`)\r\n) ";
$query4 = "INSERT INTO `{$foundation_database}` (`course_id`, `course_code`, `credit`, `course_name`, `course_ava`, `course_set`) VALUES\r\n(1, 'GCIS 500', 3, 'GCIS 500', 0, 0),\r\n(2, 'GCIS 501', 3, 'GCIS 501', 0, 0),\r\n(3, 'GCIS 502', 3, 'GCIS 502', 0, 0),\r\n(4, 'GCIS 503', 3, 'GCIS 503', 0, 0),\r\n(5, 'GCIS 504', 3, 'GCIS 504', 0, 0),\r\n(6, 'GCIS 505', 3, 'GCIS 505', 0, 2),\r\n(7, 'GCIS 506', 3, 'GCIS 506', 1, 2),\r\n(9, 'GCIS 508', 3, 'GCIS 508', 2, 0),\r\n(10, 'GCIS 509', 3, 'GCIS 509', 0, 1),\r\n(11, 'GCIS 510', 3, 'GCIS 510', 1, 1);";
/*echo $query1."<br>";
echo $query2."<br>";
echo $query3."<br>";*/
echo $query4 . "<br>";
if ($dbc->query($query1) === TRUE) {
echo "1";
if ($dbc->query($query2) === TRUE) {
echo "2";
if ($dbc->query($query3) === TRUE) {
echo "3";
if ($dbc->query($query4) === TRUE) {
echo "4";
return 1;
}
}
}
} else {
echo "Error: " . $query1 . "<br>" . $dbc->error;
}
}
示例2: NoOfMaps
function NoOfMaps($fbid)
{
$con = dbconnect();
$query = "select count(*) as count from maped m,users u where u.Fuid={$fbid} and u.UID=m.userid";
$result = mysqli_query($con, $query);
return $result;
}
示例3: dbquery
function dbquery()
{
global $kLastQuery, $kDBConnection;
// connect now, if haven't before
if (!$kDBConnection) {
$kDBConnection = dbconnect();
}
$args = func_get_args();
$query = call_user_func_array('dbprep', $args);
$kLastQuery = $query;
$query = preg_replace('/([^,\\(\\)\\s~]*)~[^,\\(\\)\\s]*/', '$1', $query);
// if it was a INSERT, UPDATE, or DELETE, see how many rows were affected
if (preg_match('/^INSERT|^UPDATE|^DELETE/i', $query)) {
$result = mysql_query($query) or trigger_error(dberror() . "\n\nThe query was: " . $query);
$count = mysql_affected_rows();
if ($count > 1) {
$fixquery = str_replace('%', '%%', $query);
//EWarning(EC_REALS_DATABASE, "Query affected multiple rows: $fixquery => $count",
// "Query affected " . $count . " rows");
}
} else {
// Replace ^NINSERT, ^NUPDATE, ^NDELETE with INSERT, UPDATE, DELETE
$query = preg_replace('/^N(INSERT|UPDATE|DELETE)/i', '$1', $query);
$result = mysql_query($query) or trigger_error(dberror() . "\n\nThe query was: " . $query);
}
if (preg_match('/^INSERT/i', $query)) {
return mysql_insert_id();
} elseif (preg_match('/^(UPDATE|DELETE)/i', $query)) {
return mysql_affected_rows();
} else {
return $result;
}
}
示例4: query
function query($query)
{
// Queries the films database with $query and returns the response
// In most cases a connection should already be initialised by the time
// any queries are run.
return dbconnect()->query($query);
}
示例5: submitquery
function submitquery($sql)
{
$link = dbconnect();
$result = mysql_query($sql) or die("Error with Query: " . mysql_error() . "<br>{$sql}</br>");
mysql_close($link);
return $result;
}
示例6: AddToDB
function AddToDB()
{
session_start();
//start a session
$db = dbconnect();
$user_id = $_SESSION['user_id'];
//pull variables
$fullName = filter_input(INPUT_POST, 'fullName');
$email = filter_input(INPUT_POST, 'Email');
$address = filter_input(INPUT_POST, 'address');
$phone = filter_input(INPUT_POST, 'phone');
$website = filter_input(INPUT_POST, 'website');
$birthday = filter_input(INPUT_POST, 'Email');
$address_group_id = filter_input(INPUT_POST, 'addressGroup');
//prepare a query
$stmt = $db->prepare("INSERT INTO address SET user_id= :user_id, address_group_id = :address_group_id, fullname = :fullname,\r\n email = :email, address = :address, phone = :phone, website = :website, birthday = :birthday");
$binds = array(":user_id" => $user_id, ":address_group_id" => $address_group_id, ":fullname" => $fullName, ":email" => $email, ":address" => $address, ":phone" => $phone, ":website" => $website, ":birthday" => $birthday);
/*
* empty()
* isset()
*/
if ($stmt->execute($binds) && $stmt->rowCount() > 0) {
//execute query
$results = 'Data Added';
}
return $results;
//return results
}
示例7: update_txp_lang
function update_txp_lang()
{
global $txp_lang_updated, $txpcfg;
if ($re = mysql_connect('textpattern.otherwords.net', 'textpattern_user', 'textpattern')) {
if (mysql_select_db('textpattern_master', $re)) {
if ($q = mysql_query("select unix_timestamp(updated) from \n\t\t\t\t\t\ttextpattern_master.update where\n\t\t\t\t\t\t`table`='txp_lang'", $re)) {
$updated = mysql_num_rows($q) != 0 ? mysql_result($q, 0) : false;
if ($updated > $txp_lang_updated) {
if ($get = mysql_query("select * from \n\t\t\t\t\t\t\t\ttextpattern_master.txp_lang order by var")) {
if (mysql_num_rows($get) > 0) {
while ($a = mysql_fetch_assoc($get)) {
$incoming[] = $a;
}
mysql_close($re);
}
if (!empty($incoming)) {
dbconnect($txpcfg['db'], $txpcfg['user'], $txpcfg['pass'], $txpcfg['host']);
safe_query("truncate txp_lang");
foreach ($incoming as $b) {
extract(doSlash($b));
safe_query("\n\t\t\t\t\t\t\t\t\t\tinsert into txp_lang set \n\t\t\t\t\t\t\t\t\t\tvar='{$var}',english='{$english}'");
}
safe_query("update txp_prefs set val= \t\n\t\t\t\t\t\t\t\t\t" . time() . "\n\t\t\t\t\t\t\t\t\twhere `name`='txp_lang_updated'", 1);
echo mysql_error();
}
}
}
}
}
}
}
示例8: isItemInDB
function isItemInDB($itemToCheck, $keyToCheck, $dbSheetToCheck)
{
$db = dbconnect();
//get list of sites to compare with site entered
$stmt = $db->prepare("SELECT * FROM {$dbSheetToCheck}");
$contentsOfDB = array();
$newArrayToCheck = array();
if ($stmt->execute() && $stmt->rowCount() > 0) {
$contentsOfDB = $stmt->fetchAll(PDO::FETCH_ASSOC);
}
// //print entire array with keys for testing purposes
// $keys = array_keys($contentsOfDB);
// for($i = 0; $i < count($contentsOfDB); $i++)
// {
// echo $keys[$i] . "{<br>";
// foreach($contentsOfDB[$keys[$i]] as $key => $value)
// {
// echo $key . " : " . $value . "<br>";
// }
// echo "}<br>";
// }
for ($i = 0; $i < count($contentsOfDB); $i++) {
$newArrayToCheck[$i] = $contentsOfDB[$i][$keyToCheck];
}
if (in_array($itemToCheck, $newArrayToCheck) == false) {
return false;
} else {
return true;
}
}
示例9: set_start
function set_start($idx)
{
global $URL, $pn;
$dbh = dbconnect();
$query = "select poll_idx,status from poll_data where poll_idx={$idx}";
$sth = dbquery($dbh, $query);
list($poll_idx, $edate) = dbselect($sth);
if (!$poll_idx) {
print_alert("존재하지 않는 데이터입니다. ", 'back');
exit;
} elseif ($status == 1) {
print_alert("현재 설문중입니다. ", 'back');
exit;
}
/* 설문 재개 */
$query = "update poll_data set status='1' where poll_idx={$idx}";
$sth = dbquery($dbh, $query);
if (!$sth) {
$msg = "에러가 발생하였습니다.<br><br>\n" . mysql_error();
print_message($msg);
} else {
header("Location: {$URL['list']}?pn={$pn}");
exit;
}
dbclose($dbh);
exit;
}
示例10: productInWinkelwagen
function productInWinkelwagen($product_id, $aantal)
{
include 'connector.php';
$db = dbconnect();
$query = "INSERT INTO WinkelwagenInhoud(product_id, aantal) VALUES({$product_id}, {$aantal});";
$result = mysql_query($query);
return $result;
}
示例11: Elimina
function Elimina($idoc)
{
$db = dbconnect();
$sqldel = "delete from productos where idoc=:id";
$querydel = $db->prepare($sqldel);
$querydel->bindParam(':id', $idoc);
$valaux = $querydel->execute();
return $valaux;
}
示例12: cargaMenuPorPerfil
function cargaMenuPorPerfil()
{
$db = dbconnect();
$query = "SELECT nombre_menu, destino_menu FROM " . $this->tabla . " WHERE id_perfil =:perfil";
$stmt = $db->prepare($query);
$stmt->bindParam(':perfil', $this->nid_perfil);
$stmt->execute();
return $stmt;
}
示例13: dbcheck
function dbcheck($config)
{
try {
dbconnect($config);
return true;
} catch (PDOException $e) {
return false;
}
}
示例14: fetchGroups
function fetchGroups()
{
$db = dbconnect();
$stmt = $db->prepare("SELECT * from address_groups");
if ($stmt->execute() && $stmt->rowCount() > 0) {
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
}
return $results;
}
示例15: updateMessage
function updateMessage()
{
$id = $_GET['id'];
$title = $_POST['title'];
$content = $_POST['content'];
$query = "UPDATE `message` SET `title`='{$title}',`content`='{$content}' WHERE `id` = {$id}";
mysqli_query(dbconnect(), $query);
header('location:index.php');
}