本文整理汇总了PHP中db_unixtimestamp函数的典型用法代码示例。如果您正苦于以下问题:PHP db_unixtimestamp函数的具体用法?PHP db_unixtimestamp怎么用?PHP db_unixtimestamp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了db_unixtimestamp函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sponsorship_cache_row
function sponsorship_cache_row($p_sponsorship_id, $p_trigger_errors = true)
{
global $g_cache_sponsorships;
$c_sponsorship_id = db_prepare_int($p_sponsorship_id);
$t_sponsorship_table = config_get('mantis_sponsorship_table');
if (isset($g_cache_sponsorships[$c_sponsorship_id])) {
return $g_cache_sponsorships[$c_sponsorship_id];
}
$query = "SELECT *\r\n\t\t\t\t FROM {$t_sponsorship_table}\r\n\t\t\t\t WHERE id='{$c_sponsorship_id}'";
$result = db_query($query);
if (0 == db_num_rows($result)) {
$g_cache_sponsorships[$c_sponsorship_id] = false;
if ($p_trigger_errors) {
error_parameters($p_sponsorship_id);
trigger_error(ERROR_SPONSORSHIP_NOT_FOUND, ERROR);
} else {
return false;
}
}
$row = db_fetch_array($result);
$row['date_submitted'] = db_unixtimestamp($row['date_submitted']);
$row['last_updated'] = db_unixtimestamp($row['last_updated']);
$g_cache_sponsorships[$c_sponsorship_id] = $row;
return $row;
}
示例2: bug_get_bugnote_stats
function bug_get_bugnote_stats($p_bug_id)
{
global $g_cache_bug;
$c_bug_id = db_prepare_int($p_bug_id);
if (!is_null($g_cache_bug[$c_bug_id]['_stats'])) {
if ($g_cache_bug[$c_bug_id]['_stats'] === false) {
return false;
} else {
$t_stats['last_modified'] = db_unixtimestamp($g_cache_bug[$c_bug_id]['_stats']['last_modified']);
$t_stats['count'] = $g_cache_bug[$c_bug_id]['_stats']['count'];
}
return $t_stats;
}
$t_bugnote_table = config_get('mantis_bugnote_table');
$query = "SELECT last_modified\n\t\t\t\t FROM {$t_bugnote_table}\n\t\t\t\t WHERE bug_id='{$c_bug_id}'\n\t\t\t\t ORDER BY last_modified DESC";
$result = db_query($query);
$row = db_fetch_array($result);
if (false === $row) {
return false;
}
$t_stats['last_modified'] = db_unixtimestamp($row['last_modified']);
$t_stats['count'] = db_num_rows($result);
return $t_stats;
}
示例3: install_date_migrate
function install_date_migrate($p_data)
{
// $p_data[0] = tablename, [1] id column, [2] = old column, [3] = new column
# Disable query logging even if enabled in config, due to possibility of mass spam
$t_log_queries = install_set_log_queries();
$t_table = $p_data[0];
$t_id_column = $p_data[1];
if (is_array($p_data[2])) {
$t_old_column = implode(',', $p_data[2]);
$t_date_array = true;
$t_cnt_fields = count($p_data[2]);
$t_pairs = array();
foreach ($p_data[3] as $var) {
array_push($t_pairs, "{$var}=" . db_param());
}
$t_new_column = implode(',', $t_pairs);
$query = "SELECT {$t_id_column}, {$t_old_column} FROM {$t_table}";
$t_first_column = true;
# In order to handle large databases where we may timeout during the upgrade, we don't
# start form the beginning everytime. Here we will only pickup rows where at least one
# of the datetime fields wasn't upgraded yet and upgrade them all.
foreach ($p_data[3] as $t_new_column_name) {
if ($t_first_column) {
$t_first_column = false;
$query .= ' WHERE ';
} else {
$query .= ' OR ';
}
$query .= "{$t_new_column_name} = 1";
}
} else {
$t_old_column = $p_data[2];
$t_new_column = $p_data[3] . "=" . db_param();
$t_date_array = false;
# The check for timestamp being = 1 is to make sure the field wasn't upgraded
# already in a previous run - see bug #12601 for more details.
$t_new_column_name = $p_data[3];
$query = "SELECT {$t_id_column}, {$t_old_column} FROM {$t_table} WHERE {$t_new_column_name} = 1";
}
$t_result = db_query_bound($query);
while ($row = db_fetch_array($t_result)) {
$t_id = (int) $row[$t_id_column];
if ($t_date_array) {
for ($i = 0; $i < $t_cnt_fields; $i++) {
$t_old_value = $row[$p_data[2][$i]];
$t_new_value[$i] = db_unixtimestamp($t_old_value);
if ($t_new_value[$i] < 100000) {
$t_new_value[$i] = 1;
}
}
$t_values = $t_new_value;
$t_values[] = $t_id;
} else {
$t_old_value = $row[$t_old_column];
$t_new_value = db_unixtimestamp($t_old_value);
if ($t_new_value < 100000) {
$t_new_value = 1;
}
$t_values = array($t_new_value, $t_id);
}
$query = "UPDATE {$t_table} SET {$t_new_column}\n\t\t\t\t\tWHERE {$t_id_column}=" . db_param();
db_query_bound($query, $t_values);
}
# Re-enable query logging if we disabled it
install_set_log_queries($t_log_queries);
# return 2 because that's what ADOdb/DataDict does when things happen properly
return 2;
}
示例4: email_queue_row_to_object
function email_queue_row_to_object($p_row)
{
# typically this function takes as an input the result of db_fetch_array() which can be false.
if ($p_row === false) {
return false;
}
$t_row = $p_row;
$t_row['submitted'] = db_unixtimestamp($t_row['submitted']);
$t_row['metadata'] = unserialize($t_row['metadata']);
$t_email_data = new EmailData();
$t_row_keys = array_keys($t_row);
$t_vars = get_object_vars($t_email_data);
# Check each variable in the class
foreach ($t_vars as $t_var => $t_value) {
# If we got a field from the DB with the same name
if (in_array($t_var, $t_row_keys, true)) {
# Store that value in the object
$t_email_data->{$t_var} = $t_row[$t_var];
}
}
return $t_email_data;
}
示例5: access_denied
if (OFF == config_get('enable_project_documentation')) {
access_denied();
}
access_ensure_project_level(config_get('view_proj_doc_threshold'), $v_project_id);
break;
}
# flush output buffer to protect download
@ob_end_clean();
# Make sure that IE can download the attachments under https.
header('Pragma: public');
header('Content-Type: ' . $v_file_type);
header('Content-Length: ' . $v_filesize);
# Added Quotes (") around file name.
header('Content-Disposition: attachment; filename="' . file_get_display_name($v_filename) . '"');
header('Content-Description: Download Data');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s \\G\\M\\T', db_unixtimestamp($v_date_added)));
# To fix an IE bug which causes problems when downloading
# attached files via HTTPS, we disable the "Pragma: no-cache"
# command when IE is used over HTTPS.
global $g_allow_file_cache;
if (isset($_SERVER["HTTPS"]) && "on" == $_SERVER["HTTPS"] && preg_match("/MSIE/", $_SERVER["HTTP_USER_AGENT"])) {
# Suppress "Pragma: no-cache" header.
} else {
if (!isset($g_allow_file_cache)) {
header('Pragma: no-cache');
}
}
header('Expires: ' . gmdate('D, d M Y H:i:s \\G\\M\\T', time()));
# dump file content to the connection.
switch (config_get('file_upload_method')) {
case DISK:
示例6: print_user
<tr>
<td class="print">
<?php
echo print_user($v3_reporter_id);
?>
</td>
</tr>
<tr>
<td class="print">
<?php
echo $v3_date_submitted;
?>
<?php
if (db_unixtimestamp($v3_date_submitted) != db_unixtimestamp($v3_last_modified)) {
echo '<br />(' . lang_get('edited_on') . ' ' . $v3_last_modified . ')';
}
?>
</td>
</tr>
</table>
</td>
<td class="nopad" valign="top" width="85%">
<table class="hide" cellspacing="1">
<tr>
<td class="print">
<?php
switch ($v3_note_type) {
case REMINDER:
echo '<div class="italic">' . lang_get('reminder_sent_to') . ': ';
示例7: create_cumulative_bydate
function create_cumulative_bydate()
{
$t_clo_val = CLOSED;
$t_res_val = config_get('bug_resolved_status_threshold');
$t_bug_table = config_get('mantis_bug_table');
$t_history_table = config_get('mantis_bug_history_table');
$t_project_id = helper_get_current_project();
$t_user_id = auth_get_current_user_id();
$specific_where = helper_project_specific_where($t_project_id, $t_user_id);
# Get all the submitted dates
$query = "SELECT date_submitted\n\t\t\t\tFROM {$t_bug_table}\n\t\t\t\tWHERE {$specific_where}\n\t\t\t\tORDER BY date_submitted";
$result = db_query($query);
$bug_count = db_num_rows($result);
for ($i = 0; $i < $bug_count; $i++) {
$row = db_fetch_array($result);
# rationalise the timestamp to a day to reduce the amount of data
$t_date = db_unixtimestamp($row['date_submitted']);
$t_date = (int) ($t_date / 86400);
if (isset($metrics[$t_date])) {
$metrics[$t_date][0]++;
} else {
$metrics[$t_date] = array(1, 0, 0);
}
}
### Get all the dates where a transition from not resolved to resolved may have happened
# also, get the last updated date for the bug as this may be all the information we have
$query = "SELECT {$t_bug_table}.id, last_updated, date_modified, new_value, old_value\n\t\t\tFROM {$t_bug_table} LEFT JOIN {$t_history_table}\n\t\t\tON {$t_bug_table}.id = {$t_history_table}.bug_id\n\t\t\tWHERE {$specific_where}\n\t\t\t\t\t\tAND {$t_bug_table}.status >= '{$t_res_val}'\n\t\t\t\t\t\tAND ( ( {$t_history_table}.new_value >= '{$t_res_val}'\n\t\t\t\t\t\t\t\tAND {$t_history_table}.field_name = 'status' )\n\t\t\t\t\t\tOR {$t_history_table}.id is NULL )\n\t\t\tORDER BY {$t_bug_table}.id, date_modified ASC";
$result = db_query($query);
$bug_count = db_num_rows($result);
$t_last_id = 0;
for ($i = 0; $i < $bug_count; $i++) {
$row = db_fetch_array($result);
$t_id = $row['id'];
# if h_last_updated is NULL, there were no appropriate history records
# (i.e. pre 0.18 data), use last_updated from bug table instead
if (NULL == $row['date_modified']) {
$t_date = db_unixtimestamp($row['last_updated']);
} else {
if ($t_res_val > $row['old_value']) {
$t_date = db_unixtimestamp($row['date_modified']);
}
}
if ($t_id != $t_last_id) {
if (0 != $t_last_id) {
# rationalise the timestamp to a day to reduce the amount of data
$t_date_index = (int) ($t_last_date / 86400);
if (isset($metrics[$t_date_index])) {
$metrics[$t_date_index][1]++;
} else {
$metrics[$t_date_index] = array(0, 1, 0);
}
}
$t_last_id = $t_id;
}
$t_last_date = $t_date;
}
ksort($metrics);
$metrics_count = count($metrics);
$t_last_opened = 0;
$t_last_resolved = 0;
foreach ($metrics as $i => $vals) {
$t_date = $i * 86400;
$t_metrics[$t_date][0] = $t_last_opened = $metrics[$i][0] + $t_last_opened;
$t_metrics[$t_date][1] = $t_last_resolved = $metrics[$i][1] + $t_last_resolved;
$t_metrics[$t_date][2] = $t_metrics[$t_date][0] - $t_metrics[$t_date][1];
}
return $t_metrics;
}
示例8: MAX
# will look up the most recent 'resolved' status change and return it as well
$query = "SELECT b.id, b.date_submitted, b.last_updated, MAX(h.date_modified) as hist_update, b.status \n FROM {$t_bug_table} b LEFT JOIN {$t_history_table} h \n ON b.id = h.bug_id AND h.type=0 AND h.field_name='status' AND h.new_value='{$t_resolved}' \n WHERE b.status >='{$t_resolved}' AND {$specific_where}\n GROUP BY b.id, b.status, b.date_submitted, b.last_updated \n ORDER BY b.id ASC";
$result = db_query($query);
$bug_count = db_num_rows($result);
$t_bug_id = 0;
$t_largest_diff = 0;
$t_total_time = 0;
for ($i = 0; $i < $bug_count; $i++) {
$row = db_fetch_array($result);
$t_date_submitted = db_unixtimestamp($row['date_submitted']);
$t_id = $row['id'];
$t_status = $row['status'];
if ($row['hist_update'] !== NULL) {
$t_last_updated = db_unixtimestamp($row['hist_update']);
} else {
$t_last_updated = db_unixtimestamp($row['last_updated']);
}
if ($t_last_updated < $t_date_submitted) {
$t_last_updated = 0;
$t_date_submitted = 0;
}
$t_diff = $t_last_updated - $t_date_submitted;
$t_total_time = $t_total_time + $t_diff;
if ($t_diff > $t_largest_diff) {
$t_largest_diff = $t_diff;
$t_bug_id = $row['id'];
}
}
if ($bug_count < 1) {
$bug_count = 1;
}
示例9: string_get_bugnote_view_link
function string_get_bugnote_view_link($p_bug_id, $p_bugnote_id, $p_user_id = null, $p_detail_info = true, $p_fqdn = false)
{
if (bug_exists($p_bug_id) && bugnote_exists($p_bugnote_id)) {
$t_link = '<a href="';
if ($p_fqdn) {
$t_link .= config_get('path');
}
$t_link .= string_get_bugnote_view_url($p_bug_id, $p_bugnote_id, $p_user_id) . '"';
if ($p_detail_info) {
$t_reporter = string_attribute(user_get_name(bugnote_get_field($p_bugnote_id, 'reporter_id')));
$t_update_date = string_attribute(date(config_get('normal_date_format'), db_unixtimestamp(bugnote_get_field($p_bugnote_id, 'last_modified'))));
$t_link .= ' title="[' . $t_update_date . '] ' . $t_reporter . '"';
}
$t_link .= '>' . lang_get('bugnote') . ': ' . bugnote_format_id($p_bugnote_id) . '</a>';
} else {
$t_link = lang_get('bugnote') . ': ' . bugnote_format_id($p_bugnote_id);
}
return $t_link;
}
示例10: news_get_limited_rows
function news_get_limited_rows($p_offset, $p_project_id = null)
{
if ($p_project_id === null) {
$p_project_id = helper_get_current_project();
}
$c_offset = db_prepare_int($p_offset);
$t_projects = current_user_get_all_accessible_subprojects($p_project_id);
$t_projects[] = $p_project_id;
if (ALL_PROJECTS != $p_project_id) {
$t_projects[] = ALL_PROJECTS;
}
$t_projects = array_map('db_prepare_int', $t_projects);
$t_news_table = config_get('mantis_news_table');
$t_news_view_limit = config_get('news_view_limit');
$t_news_view_limit_days = config_get('news_view_limit_days');
switch (config_get('news_limit_method')) {
case 0:
# BY_LIMIT - Select the news posts
$query = "SELECT *\n\t\t\t\t\t\tFROM {$t_news_table}";
if (1 == count($t_projects)) {
$c_project_id = $t_projects[0];
$query .= " WHERE project_id='{$c_project_id}'";
} else {
$query .= ' WHERE project_id IN (' . join($t_projects, ',') . ')';
}
$query .= ' ORDER BY announcement DESC, id DESC';
$result = db_query($query, $t_news_view_limit, $c_offset);
break;
case 1:
# BY_DATE - Select the news posts
$query = "SELECT *\n\t\t\t\t\t\tFROM {$t_news_table}";
if (1 == count($t_projects)) {
$c_project_id = $t_projects[0];
$query .= " WHERE project_id='{$c_project_id}'";
} else {
$query .= ' WHERE project_id IN (' . join($t_projects, ',') . ')';
}
$query .= " AND " . db_helper_compare_days(db_now(), 'date_posted', "< {$t_news_view_limit_days}") . " OR announcement = 1\n\t\t\t\t\t\tORDER BY announcement DESC, id DESC";
$result = db_query($query, $t_news_view_limit, $c_offset);
break;
}
# end switch
$t_row_count = db_num_rows($result);
$t_rows = array();
for ($i = 0; $i < $t_row_count; $i++) {
$row = db_fetch_array($result);
$row['date_posted'] = db_unixtimestamp($row['date_posted']);
array_push($t_rows, $row);
}
return $t_rows;
}
示例11: lang_get
echo lang_get('bug_notes_title');
?>
</td>
</tr>
<?php
for ($i = 0; $i < $num_notes; $i++) {
# prefix all bugnote data with v3_
$row = db_fetch_array($result);
extract($row, EXTR_PREFIX_ALL, 'v3');
if (db_unixtimestamp($v3_date_submitted) != db_unixtimestamp($v3_last_modified)) {
$t_bugnote_modified = true;
} else {
$t_bugnote_modified = false;
}
$v3_date_submitted = date(config_get('normal_date_format'), db_unixtimestamp($v3_date_submitted));
$v3_last_modified = date(config_get('normal_date_format'), db_unixtimestamp($v3_last_modified));
# grab the bugnote text and id and prefix with v3_
$query = "SELECT note\n\t\t\t\tFROM {$t_bugnote_text_table}\n\t\t\t\tWHERE id='{$v3_bugnote_text_id}'";
$result2 = db_query($query);
$row = db_fetch_array($result2);
$v3_note = $row['note'];
$v3_note = string_display_links($v3_note);
$t_bugnote_id_formatted = bugnote_format_id($v3_id);
if (VS_PRIVATE == $v3_view_state) {
$t_bugnote_css = 'bugnote-private';
$t_bugnote_note_css = 'bugnote-note-private';
} else {
$t_bugnote_css = 'bugnote-public';
$t_bugnote_note_css = 'bugnote-note-public';
}
?>
示例12: bugnote_get_all_bugnotes
function bugnote_get_all_bugnotes($p_bug_id, $p_user_bugnote_order, $p_user_bugnote_limit)
{
global $g_cache_bugnotes;
if (!isset($g_cache_bugnotes)) {
$g_cache_bugnotes = array();
}
# the cache should be aware of the sorting order
if (!isset($g_cache_bugnotes[$p_bug_id][$p_user_bugnote_order])) {
$c_bug_id = db_prepare_int($p_bug_id);
$t_bugnote_table = config_get('mantis_bugnote_table');
$t_bugnote_text_table = config_get('mantis_bugnote_text_table');
if (0 == $p_user_bugnote_limit) {
## Show all bugnotes
$t_bugnote_limit = -1;
$t_bugnote_offset = -1;
} else {
## Use offset only if order is ASC to get the last bugnotes
if ('ASC' == $p_user_bugnote_order) {
$result = db_query("SELECT COUNT(*) AS row_count FROM {$t_bugnote_table} WHERE bug_id = '{$c_bug_id}'");
$row = db_fetch_array($result);
$t_bugnote_offset = $row['row_count'] - $p_user_bugnote_limit;
} else {
$t_bugnote_offset = -1;
}
$t_bugnote_limit = $p_user_bugnote_limit;
}
# sort by bugnote id which should be more accurate than submit date, since two bugnotes
# may be submitted at the same time if submitted using a script (eg: MantisConnect).
$query = "SELECT b.*, t.note\r\n\t\t\t \tFROM {$t_bugnote_table} b\r\n\t\t\t \tLEFT JOIN {$t_bugnote_text_table} t ON b.bugnote_text_id = t.id\r\n\t\t\t \tWHERE b.bug_id = '{$c_bug_id}'\r\n\t\t\t \tORDER BY b.id {$p_user_bugnote_order}";
$t_bugnotes = array();
# BUILD bugnotes array
$result = db_query($query, $t_bugnote_limit, $t_bugnote_offset);
$count = db_num_rows($result);
for ($i = 0; $i < $count; $i++) {
$row = db_fetch_array($result);
$t_bugnote = new BugnoteData();
$t_bugnote->id = $row['id'];
$t_bugnote->bug_id = $row['bug_id'];
$t_bugnote->note = $row['note'];
$t_bugnote->view_state = $row['view_state'];
$t_bugnote->reporter_id = $row['reporter_id'];
$t_bugnote->date_submitted = db_unixtimestamp($row['date_submitted']);
$t_bugnote->last_modified = db_unixtimestamp($row['last_modified']);
$t_bugnote->note_type = $row['note_type'];
$t_bugnote->note_attr = $row['note_attr'];
$t_bugnote->time_tracking = $row['time_tracking'];
$t_bugnotes[] = $t_bugnote;
}
$g_cache_bugnotes[$p_bug_id][$p_user_bugnote_order] = $t_bugnotes;
}
return $g_cache_bugnotes[$p_bug_id][$p_user_bugnote_order];
}
示例13: print_doc_menu
?>
</td>
<td class="right">
<?php
print_doc_menu('proj_doc_page.php');
?>
</td>
</tr>
<?php
for ($i = 0; $i < $num_files; $i++) {
$row = db_fetch_array($result);
extract($row, EXTR_PREFIX_ALL, 'v');
$v_filesize = number_format($v_filesize);
$v_title = string_display($v_title);
$v_description = string_display_links($v_description);
$v_date_added = date(config_get('normal_date_format'), db_unixtimestamp($v_date_added));
?>
<tr valign="top" <?php
echo helper_alternate_class($i);
?>
>
<td>
<?php
$t_href = '<a href="file_download.php?file_id=' . $v_id . '&type=doc">';
echo $t_href;
print_file_icon($v_filename);
echo '</a> ' . $t_href . $v_title . '</a> (' . $v_filesize . ' bytes)';
?>
<br />
<span class="small">
<?php
示例14: mci_issue_get_attachments
/**
* Get the attachments of an issue.
*
* @param integer $p_issue_id The id of the issue to retrieve the attachments for
* @return Array that represents an AttachmentData structure
*/
function mci_issue_get_attachments($p_issue_id)
{
$t_attachment_rows = bug_get_attachments($p_issue_id);
$t_result = array();
foreach ($t_attachment_rows as $t_attachment_row) {
$t_attachment = array();
$t_attachment['id'] = $t_attachment_row['id'];
$t_attachment['filename'] = $t_attachment_row['filename'];
$t_attachment['size'] = $t_attachment_row['filesize'];
$t_attachment['content_type'] = $t_attachment_row['file_type'];
$t_attachment['date_submitted'] = timestamp_to_iso8601(db_unixtimestamp($t_attachment_row['date_added']));
$t_attachment['download_url'] = mci_get_mantis_path() . 'file_download.php?file_id=' . $t_attachment_row['id'] . '&type=bug';
$t_result[] = $t_attachment;
}
return $t_result;
}
示例15: string_format_complete_date
/**
* Format date for display
*/
function string_format_complete_date($p_date)
{
$t_timestamp = db_unixtimestamp($p_date);
return date(config_get('complete_date_format'), $t_timestamp);
}