本文整理汇总了PHP中mydb类的典型用法代码示例。如果您正苦于以下问题:PHP mydb类的具体用法?PHP mydb怎么用?PHP mydb使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了mydb类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update_log
function update_log($m_id, $answer)
{
$sex = getNewLogSex($m_id, $answer);
$db = new mydb();
$query = "insert into log (m_id, sex) values(\$1, \$2)";
$result = $db->query($query, array($m_id, $sex), "setlog");
}
示例2: get_questions_with_search
function get_questions_with_search($search)
{
$db = new mydb();
$query = "select c.id, c.date, c.content, m.login_name from crystal c, member m where c.m_id = m.id and c.content like \$1";
$result = $db->query($query, array("%" . $search . "%"), "search");
return $result;
}
示例3: get_my_answers
function get_my_answers($id)
{
$db = new mydb();
$query = "select q.id as q_id, q.content, c.choice, c.answer from crystal q, answer a, choices c where a.q_id = q.id and a.answer = c.id and a.m_id = \$1";
$result = $db->query($query, array($id), "getans");
return $result;
}
示例4: get_choices
function get_choices($id)
{
$db = new mydb();
$query = "select * from choices c where c.q_id = \$1";
$result = $db->query($query, array($id), "choices");
return $result;
}
示例5: getNewLogSex
function getNewLogSex($id, $n)
{
$db = new mydb();
$query = "select c.answer from answer a, choices c where a.m_id = \$1 and c.id = a.answer";
$result = $db->query($query, array($id), "getNewLogSex");
$num = pg_num_rows($result);
$sum = 0;
if ($num == 0) {
return "1000";
}
for ($i = 0; $i < $num; $i++) {
$row = pg_fetch_assoc($result, $i);
$sum += intval($row['answer']);
}
$sum += $n;
return $sum / ($num + 1);
}
示例6: next_photo
function next_photo()
{
// Find the ID of the next photo to use
$query = "SELECT id FROM photo_of_the_week ORDER BY last_date_used,id LIMIT 1";
$result = mydb::cxn()->query($query);
$row = $result->fetch_assoc();
$next_photo_id = $row['id'];
$query = "UPDATE photo_of_the_week SET last_date_used = curdate() where id = " . $next_photo_id;
$result = mydb::cxn()->query($query);
}
示例7: exists
public function exists($id = false)
{
if (is_numeric($id)) {
mydb::cxn()->query('SELECT count(*) FROM scheduled_courses WHERE id = ' . $id);
if (mydb::cxn()->affected_rows >= 1) {
return 1;
}
} else {
return 0;
}
}
示例8: get_chuck_norris_fact
function get_chuck_norris_fact()
{
//require_once("scripts/connect.php");
//$dbh = connect();
$query = "SELECT MAX(id) as max, MIN(id) as min from chuck_norris_facts";
$result = mydb::cxn()->query($query);
$row = $result->fetch_assoc();
$min_id = $row['min'];
$max_id = $row['max'];
$id = rand($min_id, $max_id);
$query = "SELECT fact FROM chuck_norris_facts WHERE id LIKE '" . $id . "'";
$result = mydb::cxn()->query($query);
$row = $result->fetch_assoc();
echo $row['fact'];
}
示例9: check_hrap
function check_hrap($hrap_id)
{
// This function will accept an INTEGER and check for a corresponding HRAP ID in the database (hraps.id).
// If the requested hrap exists, the function returns the rappeller's full name (as a string).
// If the requested hrap does not exist, or a non-integer value is passed, return 0
if (is_numeric($hrap_id) && intval($hrap_id) == floatval($hrap_id)) {
//Match an integer value
$query = "SELECT firstname, lastname FROM hraps WHERE id = " . $hrap_id;
$result = mydb::cxn()->query($query);
if (mydb::cxn()->affected_rows > 0) {
$row = $result->fetch_assoc();
return $row['firstname'] . " " . $row['lastname'];
}
}
return 0;
}
示例10: is_valid
function is_valid($year)
{
//Check to see if a given year is present in the database
// Return 1 if given year is valid
// Return 0 otherwise
$result = mydb::cxn()->query("SELECT DISTINCT year FROM roster");
if (mydb::cxn()->error != '') {
die("Retrieving valid YEARs failed: " . mydb::cxn()->error . "<br>\n" . $query);
}
while ($row = $result->fetch_assoc()) {
if ($row['year'] == $year) {
return 1;
}
}
return 0;
//Year is NOT valid or else function would have returned 1 by now
}
示例11: build_auth_info_array
function build_auth_info_array()
{
global $auth_info;
$query = "SELECT id, username, real_name, access_level FROM authentication WHERE 1 ORDER BY username";
$result = mydb::cxn()->query($query) or die("Error retrieving usernames for edit_user list: " . mydb::cxn()->error);
//Build a local array of access privileges for each user
$access_levels = array('account_management', 'backup_restore', 'roster', 'edit_phonelist', 'inventory', 'edit_incidents', 'budget_helper', 'budget_helper_admin', 'flight_hours', 'crew_status', 'photos', 'update_jobs', 'order_apparel', 'manage_apparel');
while ($row = $result->fetch_assoc()) {
$auth_info[$row['id']] = array('username' => $row['username'], 'real_name' => $row['real_name'], 'id' => $row['id']);
foreach ($access_levels as $area) {
if (strpos($row['access_level'], $area) !== false) {
$auth_info[$row['id']][$area] = 1;
} else {
$auth_info[$row['id']][$area] = 0;
}
}
}
}
示例12: update_rss_feed
function update_rss_feed()
{
$description_length = 300;
$title_length = 40;
$num_entries = 4;
// The number of blog entries to include in the RSS feed
$query = "SELECT name, unix_timestamp(date) as date, status FROM current_sticky WHERE 1";
$result = mydb::cxn()->query($query);
$sticky = $result->fetch_assoc();
$query = "SELECT name, unix_timestamp(date) as date, status FROM current ORDER BY date DESC LIMIT " . $num_entries;
$result = mydb::cxn()->query($query);
$rss = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n\n" . "<rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\">\n" . "<channel>\n\n" . "<title>SRC - Crew Status</title>\n" . "<link>http://www.siskiyourappellers.com/current.php</link>\n" . "<description>\n" . "\tThe Crew Status Page provides information on the whereabouts of crewmembers\n" . "\tand the various projects that we're currently working on.\n" . "</description>\n\n" . "<atom:link href=\"http://www.siskiyourappellers.com/rss.php\" rel=\"self\" type=\"application/rss+xml\" />\n" . "<lastBuildDate>" . date("r") . "</lastBuildDate>\n" . "<language>en-us</language>\n\n";
//Post the "sticky" content at the top of the RSS Feed
if (strlen($sticky['status']) > 0) {
if (strlen($sticky['status']) > $title_length) {
$content_title = substr($sticky['status'], 0, $title_length) . "...";
} else {
$content_title = $sticky['status'];
}
$timestamp_sticky = date("r", $sticky['date']);
$timestamp_title = date("M jS", $sticky['date']);
$rss .= "<item>\n" . "<title>[!] " . $content_title . "</title>\n" . "<link>http://www.siskiyourappellers.com/current.php</link>\n" . "<guid>http://www.siskiyourappellers.com/current.php?id=" . $sticky['date'] . "</guid>\n" . "<pubDate>" . $timestamp_sticky . "</pubDate>\n" . "<description>" . $sticky['status'] . "</description>\n" . "</item>\n\n";
}
//Add the most recent updates to the RSS feed
while ($row = $result->fetch_assoc()) {
//Replace <br> with a single space - " "
$status = str_replace(array("<br>", "<br />", "<BR>", "<BR />"), " ", $row['status']);
//Generate a Title for this update
if (strlen($status) > $title_length) {
$content_title = substr($status, 0, $title_length) . "...";
} else {
$content_title = $status;
}
//Format the date strings
$timestamp_status = date("r", $row['date']);
$timestamp_title = date("M jS", $row['date']);
$rss .= "<item>\n" . "<title>[" . $timestamp_title . "] " . $content_title . "</title>\n" . "<link>http://www.siskiyourappellers.com/current.php</link>\n" . "<guid>http://www.siskiyourappellers.com/current.php?id=" . $row['date'] . "</guid>\n" . "<pubDate>" . $timestamp_status . "</pubDate>\n" . "<description>" . $status . "</description>\n" . "</item>\n\n";
}
// END WHILE
$rss .= "</channel>\n" . "</rss>\n";
//Open the rss.xml file for writing
$rss_file = fopen("../rss.xml", "w");
fwrite($rss_file, $rss);
}
示例13: set
function set($var, $value)
{
// This function handles a SPECIAL CASE where the use_offset is queried for a ROPE object. This is special because a ROPE has a different use_offset
// for each end (end 'a' and end 'b'), which are serialized into a single STRING value for database storage.
// If this set function is called and the special case does not apply, the 'set' function in the parent class will be invoked.
$value = strtolower(mydb::cxn()->real_escape_string($value));
switch ($var) {
case 'use_offset':
if ($value == "") {
$this->use_offset = 'a0,b0';
} elseif (preg_match('/\\ba\\d{1,3},b\\d{1,3}\\b/', $value) != 1) {
throw new Exception('The USE OFFSET for a rope must include both the \'A\' end and the \'B\' end.');
} else {
$this->use_offset = $value;
}
case 'use_offset_a':
if ($value == "") {
$this->use_offset = 'a0,b0';
}
if ($this->var_is_int($value) && $value >= 0) {
$this->use_offset = 'a' . $value . ',b' . $this->get_use_offset('b');
} else {
throw new Exception('The use-offset for end \'A\' must be a number greater than or equal to zero.');
}
break;
case 'use_offset_b':
if ($this->var_is_int($value) && $value >= 0) {
$this->use_offset = 'a' . $this->get_use_offset('a') . ',b' . $value;
} else {
throw new Exception('The use-offset for end \'B\' must be a number greater than or equal to zero.');
}
break;
default:
parent::set($var, $value);
}
// End: switch()
}
示例14: update_or_insert_paycheck
function update_or_insert_paycheck($year, $payperiod, $person_id, $status)
{
//This function will change the STATUS of a specific paycheck.
//Sanitize inputs
$year = mydb::cxn()->real_escape_string($year);
$payperiod = mydb::cxn()->real_escape_string($payperiod);
$person_id = mydb::cxn()->real_escape_string($person_id);
$status = mydb::cxn()->real_escape_string($status);
//Check to see if this paycheck is already in the database
$query = "\tSELECT id FROM paychecks\n\t\t\t\t\tWHERE \tpaychecks.year = " . $year . "\n\t\t\t\t\tAND\t\tpaychecks.payperiod = " . $payperiod . "\n\t\t\t\t\tAND\t\tpaychecks.crewmember_id = " . $person_id;
$result = mydb::cxn()->query($query);
$row = $result->fetch_assoc();
echo $query . "<br /><br />\n\n";
if ($result->num_rows > 0) {
// This paycheck is already in the database. UPDATE the status.
$query = "UPDATE paychecks SET status = " . $status . " WHERE id = " . $row['id'];
$result = mydb::cxn()->query($query);
} else {
// This paycheck is NOT in the database. INSERT it with the requested status.
$query = "\tINSERT INTO paychecks (year,payperiod,crewmember_id,status)\n\t\t\t\t\t\tvalues(" . $year . "," . $payperiod . "," . $person_id . "," . $status . ")";
$result = mydb::cxn()->query($query);
}
echo $query . "\n\n" . mydb::cxn()->error;
}
示例15: dirname
<!DOCTYPE html>
<?php
include_once dirname(__FILE__) . "/functions/inc/mydb.inc.php";
$db = new mydb();
$categorias = $db->consulta("SELECT * FROM categoria_producto WHERE idioma_id=1 AND catp_eliminado=0 AND catp_publicado=1");
?>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<title>Texur</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link href="global/css/bootstrap.min.css" rel="stylesheet">
<!-- <link href="//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.min.css" rel="stylesheet">
<!--[if lt IE 9]>
<script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link href="global/css/styles.css" rel="stylesheet">
</head>
<body>
<nav class="navbar navbar-fixed-top" style="background-color:#0A376E;color:#b2aa00;">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand " href="index.html" > <b>Home</b>
</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a href="#">Cursos/Tutoriales</a></li>
<li><a href="#">Manuales</a></li>