本文整理汇总了PHP中mydb::cxn方法的典型用法代码示例。如果您正苦于以下问题:PHP mydb::cxn方法的具体用法?PHP mydb::cxn怎么用?PHP mydb::cxn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mydb
的用法示例。
在下文中一共展示了mydb::cxn方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: 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;
}
}
示例3: 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'];
}
示例4: 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;
}
示例5: 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
}
示例6: 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;
}
}
}
}
示例7: 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);
}
示例8: 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()
}
示例9: 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;
}
示例10: show_add_eq_form
function show_add_eq_form($eq_type, $msg = "")
{
$field1 = "";
$field2 = "";
$field3 = "";
$field4 = $_SESSION['current_view']['crew']->get('id');
if ($msg != "" && $msg != "Your equipment has been added.") {
//If an error was thrown, repopulate the form with the POST'ed values
$field1 = $_POST['eq_num1'];
$field2 = $_POST['eq_num2'];
$field3 = $_POST['in_service_date'];
$field4 = $_POST['crew_affiliation_id'];
}
// Build Crew selection menu AND
// Build a hidden list of Crew Abbreviations.
// This list is used to update the equipment # field in the modify_equipment_form when the Ownership is changed
echo "<form action=\"\" method=\"GET\" id=\"abbrev_list\">\n";
$query = "SELECT DISTINCT id, name, abbrev FROM crews ORDER BY name";
$result = mydb::cxn()->query($query);
$crew_menu = "";
while ($row = $result->fetch_assoc()) {
if ($field4 == $row['id']) {
$crew_menu .= "<option value=\"" . $row['id'] . "\" selected=\"selected\">" . $row['name'] . "</option>\n";
$abbrev = $row['abbrev'];
} elseif ($_SESSION['current_user']->get('account_type') == 'admin' || $row['id'] == get_academy_id($_SESSION['current_user']->get('region'))) {
$crew_menu .= "<option value=\"" . $row['id'] . "\">" . $row['name'] . "</option>\n";
}
echo "<input type=\"hidden\" name=\"crew_" . $row['id'] . "_abbrev\" id=\"crew_" . $row['id'] . "_abbrev\" value=\"" . $row['abbrev'] . "\">\n";
}
echo "</form>\n\n";
echo "<br><div class=\"error_msg\">" . $msg . "</div>\n";
echo "<form id=\"modify_equipment_form\" method=\"post\" action=\"add_new_equipment.php?crew=" . $_GET['crew'] . "&eq_type=" . $eq_type . "\" style=\"text-align:center;\">\n\t\t\t\t\t<input type=\"hidden\" name=\"eq_type\" value=\"" . $eq_type . "\">\n\t\t\t\t\t<table width=\"500\" style=\"border:2px solid #555555; background-color:#bbbbbb;margin:25px auto 0 auto;\">\n\t\t\t\t\t\t<tr><td colspan=\"2\" style=\"text-align:left; font-size:15px; font-weight:bold;\">Add a New " . ucwords(str_replace("_", " ", $eq_type)) . "</td></tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td style=\"width:150px;\">" . ucwords(str_replace("_", " ", $eq_type)) . " #:</td>\n\t\t\t\t\t\t\t<td style=\"width:auto;text-align:left;\">\n\t\t\t\t\t\t\t\t<input type=\"text\" name=\"eq_num1\" id=\"eq_abbrev\" value=\"" . $abbrev . "\" style=\"width:2.5em; background-color:#bbbbbb; border:none; text-transform:uppercase; text-align:right;\" readonly=\"readonly\"/> -\n\t\t\t\t\t\t\t\t<span id=\"eq_num2_spry\">\n\t\t\t\t\t\t\t\t<input type=\"text\" name=\"eq_num2\" id=\"eq_num2\" value=\"" . $field2 . "\" style=\"width:4.5em\"/>\n\t\t\t\t\t\t\t\t\t<span class=\"textfieldRequiredMsg\">Required</span>\n\t\t\t\t\t\t\t\t\t<span class=\"textfieldInvalidFormatMsg\">Must be a 3-7 digit number.</span>\n\t\t\t\t\t\t\t\t\t<span class=\"textfieldMinCharsMsg\">Must be 3 digits.</span>\n\t\t\t\t\t\t\t\t\t<span class=\"textfieldMaxCharsMsg\">Must be 7 digits.</span>\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>";
if ($eq_type == 'rope') {
echo "<tr><td>Unrecorded uses<br />on End 'A':</td><td style=\"text-align:left\"><input type=\"text\" name=\"use_offset_a\" style=\"width:2.5em\"></td></tr>\n" . "<tr><td>Unrecorded uses<br />on End 'B':</td><td style=\"text-align:left\"><input type=\"text\" name=\"use_offset_b\" style=\"width:2.5em\"></td></tr>\n";
} else {
echo "<tr><td>Unrecorded uses:</td><td style=\"text-align:left\"><input type=\"text\" name=\"use_offset\" style=\"width:2.5em\"></td></tr>\n";
}
echo "\t\t<tr>\n\t\t\t\t\t\t\t<td>Manufacture Date:</td>\n\t\t\t\t\t\t\t<td style=\"text-align:left\">\n\t\t\t\t\t\t\t\t<span id=\"in_service_date_spry\">\n\t\t\t\t\t\t\t\t\t<input type=\"text\" name=\"in_service_date\" id=\"in_service_date\" style=\"width:5em\" value=\"" . $field3 . "\" onFocus=\"showCal('equipment_in_service_date')\" />\n\t\t\t\t\t\t\t\t\t<span class=\"textfieldRequiredMsg\">Required</span>\n\t\t\t\t\t\t\t\t\t<span class=\"textfieldInvalidFormatMsg\">Date must be: mm/dd/yyyy</span>\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Ownership:</td>\n\t\t\t\t\t\t\t<td style=\"text-align:left\"><select name=\"crew_affiliation_id\" id=\"crew_affiliation_id\" onchange=\"updateAbbrev()\">" . $crew_menu . "</select></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td colspan=\"2\" style=\"text-align:center\"><input name=\"submit\" type=\"submit\" class=\"form_button\" style=\"width:150px\" value=\"Save\" /></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</table>\n\t\t\t\t</form>";
}
示例11: populate_requisition_by_id
function populate_requisition_by_id($id)
{
/* Check id validity here */
$requisition_id = mydb::cxn()->real_escape_string($_GET['id']);
$query = "SELECT count(*) as num FROM requisitions WHERE id = " . $requisition_id;
$result = mydb::cxn()->query($query);
$row = $result->fetch_assoc();
if ($row['num'] == 0) {
throw new Exception('The requested requisition does not exist (Requisition #' . $requisition_id . ').');
}
$query = "SELECT\n\t\t\t requisitions.id,\n requisitions.added_by,\n\t\t\t requisitions.vendor_info,\n\t\t\t requisitions.description,\n\t\t\t requisitions.attachment1, \n\t\t\t requisitions.attachment2,\n\t\t\t requisitions.attachment3,\n\t\t\t round(requisitions.amount,2) as order_total,\n\t\t\t requisitions.card_used,\n\t\t\t date_format(requisitions.date,'%m/%d/%Y') as date,\n\t\t\t requisitions_split.id as split_id,\n\t\t\t requisitions_split.comments as split_comments,\n\t\t\t requisitions_split.s_number,\n\t\t\t requisitions_split.charge_code,\n\t\t\t requisitions_split.override,\n\t\t\t round(requisitions_split.amount,2) as amount,\n\t\t\t requisitions_split.received as split_received,\n\t\t\t requisitions_split.reconciled as split_reconciled\n\t\t\t FROM requisitions LEFT OUTER JOIN requisitions_split \n\t\t\t ON requisitions.id = requisitions_split.requisition_id\n\t\t\t WHERE requisitions.id = " . $id . "\n\t\t\t ORDER BY split_id";
$result = mydb::cxn()->query($query);
if (!$result) {
throw new Exception('Database error: ' . mydb::cxn()->error);
}
$_SESSION['form_memory']['requisition'] = array();
while ($row = $result->fetch_assoc()) {
$_SESSION['form_memory']['requisition'][] = $row;
}
return;
}
示例12: Exception
}
else {
// Access Denied.
header('location: http://www.siskiyourappellers.com/admin/index.php');
}
*/
try {
$req_id = mydb::cxn()->real_escape_string($_GET['req_id']);
$attachment_num = mydb::cxn()->real_escape_string($_GET['attachment_num']);
$query = "SELECT attachment" . $attachment_num . " FROM requisitions WHERE id = " . $req_id;
$result = mydb::cxn()->query($query);
if (mydb::cxn()->affected_rows > 0) {
$row = $result->fetch_assoc();
$attachment_path = $row['attachment' . $attachment_num];
} else {
throw new Exception('Requisition #' . $req_id . ' doesn\'t appear to have an Attachment #' . $attachment_num . '!');
exit;
}
if (!unlink($_SERVER['DOCUMENT_ROOT'] . "/admin/" . $attachment_path)) {
throw new Exception('Attachment #' . $attachment_num . ' could not be deleted.');
} else {
$query = "UPDATE requisitions SET attachment" . $attachment_num . " = NULL WHERE id = " . $req_id;
$result = mydb::cxn()->query($query);
if (mydb::cxn()->error != '') {
throw new Exception('Attachment #' . $attachment_num . ' was deleted, but the database entry still exists: ' . mydb::cxn()->error);
}
}
} catch (Exception $e) {
echo $e->getMessage();
}
return true;
示例13: unix_timestamp
$query = "SELECT query, unix_timestamp(creation_date) as creation_date, (days_until_expiration * 24 * 3600) as exp_interval FROM confirmation WHERE code = '" . mydb::cxn()->real_escape_string($_GET['verification']) . "'";
$result = mydb::cxn()->query($query);
$row = $result->fetch_assoc();
if ($row['query'] == "") {
echo "That confirmation code is invalid<br>\n";
} elseif ($row['creation_date'] + $row['exp_interval'] < time()) {
echo "<div class=\"error_msg\" style=\"margin:0 auto 0 auto;\">That confirmation code has expired!</div>\n";
$query = "DELETE from confirmation WHERE code = '" . mydb::cxn()->real_escape_string($_GET['verification']) . "'";
$result = mydb::cxn()->query($query);
} else {
if (!mydb::cxn()->multi_query($row['query'])) {
echo "<div class=\"error_msg\" style=\"margin:0 auto 0 auto;\">There was a problem confirming your request.</div>\n";
} else {
while (mydb::cxn()->next_result()) {
mydb::cxn()->store_result();
}
//Clear the buffer from the dB multi_query
echo "<div class=\"error_msg\" style=\"margin:0 auto 0 auto;\">Your request has been confirmed.</div>";
$query = "DELETE from confirmation WHERE code = '" . mydb::cxn()->real_escape_string($_GET['verification']) . "'";
$result = mydb::cxn()->query($query);
echo mydb::cxn()->error;
}
}
}
?>
</div> <!-- End 'content' -->
<div style="clear:both; display:block; visibility:hidden;"></div>
</body>
</html>
示例14: exists
static function exists($hrap_id = false)
{
// Returns TRUE if $hrap_id is found in the 'hraps' database table
// Returns FALSE otherwise.
// This function will take any data type as input.
if (!$hrap_id) {
return false;
}
$query = "SELECT id FROM hraps WHERE id = " . mydb::cxn()->real_escape_string($hrap_id);
$result = mydb::cxn()->query($query);
if (mydb::cxn()->affected_rows > 0) {
return TRUE;
} else {
return FALSE;
}
}
示例15: item_id_exists
function item_id_exists($item_id = '')
{
// This function checks the database to see if an item exists with the ID specified by $item_id
// Return TRUE if an item exists
// Return FALSE otherwise
if ($item_id != '') {
$query = "SELECT * FROM items WHERE id = '" . mydb::cxn()->real_escape_string($item_id) . "'";
$result = mydb::cxn()->query($query);
return $result->num_rows > 0 ? TRUE : FALSE;
} else {
return FALSE;
}
}