当前位置: 首页>>代码示例>>PHP>>正文


PHP DateTimeValue::toMySQL方法代码示例

本文整理汇总了PHP中DateTimeValue::toMySQL方法的典型用法代码示例。如果您正苦于以下问题:PHP DateTimeValue::toMySQL方法的具体用法?PHP DateTimeValue::toMySQL怎么用?PHP DateTimeValue::toMySQL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DateTimeValue的用法示例。


在下文中一共展示了DateTimeValue::toMySQL方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: ExecuteQuery

 function ExecuteQuery()
 {
     $this->data = array();
     $date = new DateTimeValue(Time());
     $notYet = ProjectTasks::findAll(array('conditions' => 'created_by_id = ' . logged_user()->getId() . ' AND ( due_date = \'0000-00-00 00:00:00\' OR due_date > \'' . substr($date->toMySQL(), 0, strpos($date->toMySQL(), ' ')) . "')"));
     $today = ProjectTasks::findAll(array('conditions' => 'created_by_id = ' . logged_user()->getId() . ' AND due_date = \'' . substr($date->toMySQL(), 0, strpos($date->toMySQL(), ' ')) . "'"));
     $past = ProjectTasks::findAll(array('conditions' => 'created_by_id = ' . logged_user()->getId() . ' AND due_date > \'1900-01-01 00:00:00\' AND due_date < \'' . substr($date->toMySQL(), 0, strpos($date->toMySQL(), ' ')) . "'"));
     $value = 0;
     if (isset($past)) {
         $value = count($past);
     }
     $this->data['values'][0]['labels'][] = 'Overdue';
     $this->data['values'][0]['values'][] = $value;
     $value = 0;
     if (isset($notYet)) {
         $value = count($notYet);
     }
     $this->data['values'][0]['labels'][] = 'Not yet due';
     $this->data['values'][0]['values'][] = $value;
     $value = 0;
     if (isset($today)) {
         $value = count($today);
     }
     $this->data['values'][0]['labels'][] = 'Due today';
     $this->data['values'][0]['values'][] = $value;
 }
开发者ID:abhinay100,项目名称:feng_app,代码行数:26,代码来源:TasksByDueDate.class.php

示例2: SaveMail

 function SaveMail(&$content, MailAccount $account, $uidl, $state = 0, $imap_folder_name = '')
 {
     if (defined('DEBUG_EMAIL_RETRIEVAL') && DEBUG_EMAIL_RETRIEVAL) {
         self::log_connection_status();
         Logger::log("UID: {$uidl}");
     }
     if (!mysql_ping(DB::connection()->getLink())) {
         DB::connection()->reconnect();
         Logger::log("*** Connection Lost -> Reconnected ***");
     }
     if (defined('DEBUG_EMAIL_RETRIEVAL') && DEBUG_EMAIL_RETRIEVAL) {
         Logger::log("mem  1) " . format_filesize(memory_get_usage()));
     }
     if (strpos($content, '+OK ') > 0) {
         $content = substr($content, strpos($content, '+OK '));
     }
     if (defined('DEBUG_EMAIL_RETRIEVAL') && DEBUG_EMAIL_RETRIEVAL) {
         Logger::log("mem  2) " . format_filesize(memory_get_usage()));
     }
     self::parseMail($content, $decoded, $parsedMail, $warnings);
     if (defined('DEBUG_EMAIL_RETRIEVAL') && DEBUG_EMAIL_RETRIEVAL) {
         Logger::log("mem  3) " . format_filesize(memory_get_usage()));
     }
     $encoding = array_var($parsedMail, 'Encoding', 'UTF-8');
     $enc_conv = EncodingConverter::instance();
     $to_addresses = self::getAddresses(array_var($parsedMail, "To"));
     $from = self::getAddresses(array_var($parsedMail, "From"));
     $message_id = self::getHeaderValueFromContent($content, "Message-ID");
     $in_reply_to_id = self::getHeaderValueFromContent($content, "In-Reply-To");
     if (defined('DEBUG_EMAIL_RETRIEVAL') && DEBUG_EMAIL_RETRIEVAL) {
         Logger::log("mem  4) " . format_filesize(memory_get_usage()));
     }
     $uid = trim($uidl);
     if (str_starts_with($uid, '<') && str_ends_with($uid, '>')) {
         $uid = utf8_substr($uid, 1, utf8_strlen($uid, $encoding) - 2, $encoding);
     }
     if ($uid == '') {
         $uid = trim($message_id);
         if ($uid == '') {
             $uid = array_var($parsedMail, 'Subject', 'MISSING UID');
         }
         if (str_starts_with($uid, '<') && str_ends_with($uid, '>')) {
             $uid = utf8_substr($uid, 1, utf8_strlen($uid, $encoding) - 2, $encoding);
         }
         if (MailContents::mailRecordExists($account->getId(), $uid, $imap_folder_name == '' ? null : $imap_folder_name)) {
             return;
         }
     }
     if (!$from) {
         $parsedMail["From"] = self::getFromAddressFromContent($content);
         $from = array_var($parsedMail["From"][0], 'address', '');
         if (defined('DEBUG_EMAIL_RETRIEVAL') && DEBUG_EMAIL_RETRIEVAL) {
             Logger::log("mem  4.1) " . format_filesize(memory_get_usage()));
         }
     }
     if (defined('DEBUG_EMAIL_RETRIEVAL') && DEBUG_EMAIL_RETRIEVAL) {
         Logger::log("mem  5) " . format_filesize(memory_get_usage()));
     }
     if (defined('EMAIL_MESSAGEID_CONTROL') && EMAIL_MESSAGEID_CONTROL) {
         if (trim($message_id) != "") {
             $id_condition = " AND `message_id`='" . trim($message_id) . "'";
         } else {
             $id_condition = " AND `subject`='" . trim(array_var($parsedMail, 'Subject')) . "' AND `from`='{$from}'";
             if (array_var($parsedMail, 'Date')) {
                 $sent_date_dt = new DateTimeValue(strtotime(array_var($parsedMail, 'Date')));
                 $sent_date_str = $sent_date_dt->toMySQL();
                 $id_condition .= " AND `sent_date`='" . $sent_date_str . "'";
             }
         }
         $same = MailContents::findOne(array('conditions' => "`account_id`=" . $account->getId() . $id_condition, 'include_trashed' => true));
         if ($same instanceof MailContent) {
             return;
         }
     }
     if ($state == 0) {
         if ($from == $account->getEmailAddress()) {
             if (strpos($to_addresses, $from) !== FALSE) {
                 $state = 5;
             } else {
                 $state = 1;
             }
             //Show only in sent folder
         }
     }
     if (defined('DEBUG_EMAIL_RETRIEVAL') && DEBUG_EMAIL_RETRIEVAL) {
         Logger::log("mem  6) " . format_filesize(memory_get_usage()));
         self::log_connection_status();
     }
     $from_spam_junk_folder = strpos(strtolower($imap_folder_name), 'spam') !== FALSE || strpos(strtolower($imap_folder_name), 'junk') !== FALSE || strpos(strtolower($imap_folder_name), 'trash') !== FALSE;
     $user_id = logged_user() instanceof User ? logged_user()->getId() : $account->getUserId();
     if (defined('DEBUG_EMAIL_RETRIEVAL') && DEBUG_EMAIL_RETRIEVAL) {
         self::log_connection_status();
     }
     $max_spam_level = user_config_option('max_spam_level', null, $user_id);
     if ($max_spam_level < 0) {
         $max_spam_level = 0;
     }
     $mail_spam_level = strlen(trim(array_var($decoded[0]['Headers'], 'x-spam-level:', '')));
     // if max_spam_level >= 10 then nothing goes to junk folder
     $spam_in_subject = false;
//.........这里部分代码省略.........
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:101,代码来源:MailUtilities.class.php

示例3: phpToRaw

 /**
 * Conver $value to raw value
 *
 * @param DateTimeValue $value
 * @return null
 */
 protected function phpToRaw($value) {
   return $value instanceof DateTimeValue ? $value->toMySQL() : EMPTY_DATETIME;
 } // phpToRaw
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:9,代码来源:DateTimeConfigHandler.class.php

示例4: SaveMail

 function SaveMail(&$content, MailAccount $account, $uidl, $state = 0, $imap_folder_name = '', $read = null, &$received_count)
 {
     try {
         if (strpos($content, '+OK ') > 0) {
             $content = substr($content, strpos($content, '+OK '));
         }
         self::parseMail($content, $decoded, $parsedMail, $warnings);
         $encoding = array_var($parsedMail, 'Encoding', 'UTF-8');
         $enc_conv = EncodingConverter::instance();
         $to_addresses = self::getAddresses(array_var($parsedMail, "To"));
         $from = self::getAddresses(array_var($parsedMail, "From"));
         $message_id = self::getHeaderValueFromContent($content, "Message-ID");
         $in_reply_to_id = self::getHeaderValueFromContent($content, "In-Reply-To");
         $uid = trim($uidl);
         if (str_starts_with($uid, '<') && str_ends_with($uid, '>')) {
             $uid = utf8_substr($uid, 1, utf8_strlen($uid, $encoding) - 2, $encoding);
         }
         if ($uid == '') {
             $uid = trim($message_id);
             if ($uid == '') {
                 $uid = array_var($parsedMail, 'Subject', 'MISSING UID');
             }
             if (str_starts_with($uid, '<') && str_ends_with($uid, '>')) {
                 $uid = utf8_substr($uid, 1, utf8_strlen($uid, $encoding) - 2, $encoding);
             }
         }
         // do not save duplicate emails
         if (MailContents::mailRecordExists($account->getId(), $uid, $imap_folder_name == '' ? null : $imap_folder_name)) {
             return;
         }
         if (!$from) {
             $parsedMail["From"] = self::getFromAddressFromContent($content);
             $from = array_var($parsedMail["From"][0], 'address', '');
         }
         if (defined('EMAIL_MESSAGEID_CONTROL') && EMAIL_MESSAGEID_CONTROL) {
             if (trim($message_id) != "") {
                 $id_condition = " AND `message_id`='" . trim($message_id) . "' AND `from`='{$from}'";
             } else {
                 $id_condition = " AND `name`= " . DB::escape(trim(array_var($parsedMail, 'Subject'))) . " AND `from`='{$from}'";
                 if (array_var($parsedMail, 'Date')) {
                     $sent_date_dt = new DateTimeValue(strtotime(array_var($parsedMail, 'Date')));
                     $sent_date_str = $sent_date_dt->toMySQL();
                     $id_condition .= " AND `sent_date`='" . $sent_date_str . "'";
                 }
             }
             $same = MailContents::findOne(array('conditions' => "`account_id`=" . $account->getId() . $id_condition, 'include_trashed' => true));
             if ($same instanceof MailContent) {
                 return;
             }
         }
         $from_spam_junk_folder = strpos(strtolower($imap_folder_name), 'spam') !== FALSE || strpos(strtolower($imap_folder_name), 'junk') !== FALSE || strpos(strtolower($imap_folder_name), 'trash') !== FALSE;
         $user_id = logged_user() instanceof Contact ? logged_user()->getId() : $account->getContactId();
         $max_spam_level = user_config_option('max_spam_level', null, $user_id);
         if ($max_spam_level < 0) {
             $max_spam_level = 0;
         }
         $spam_level_header = 'x-spam-level:';
         foreach ($decoded[0]['Headers'] as $hdr_name => $hdrval) {
             if (strpos(strtolower($hdr_name), "spamscore") !== false || strpos(strtolower($hdr_name), "x-spam-level")) {
                 $spam_level_header = $hdr_name;
                 break;
             }
         }
         $mail_spam_level = strlen(trim(array_var($decoded[0]['Headers'], $spam_level_header, '')));
         // if max_spam_level >= 10 then nothing goes to junk folder
         $spam_in_subject = false;
         if (config_option('check_spam_in_subject')) {
             $spam_in_subject = strpos_utf(strtoupper(array_var($parsedMail, 'Subject')), "**SPAM**") !== false;
         }
         if ($max_spam_level < 10 && ($mail_spam_level > $max_spam_level || $from_spam_junk_folder) || $spam_in_subject) {
             $state = 4;
             // send to Junk folder
         }
         //if you are in the table spam MailSpamFilters
         if ($state != 4) {
             $spam_email = MailSpamFilters::getFrom($account->getId(), $from);
             if ($spam_email) {
                 $state = 0;
                 if ($spam_email[0]->getSpamState() == "spam") {
                     $state = 4;
                 }
             } else {
                 if ($state == 0) {
                     if (strtolower($from) == strtolower($account->getEmailAddress())) {
                         if (strpos($to_addresses, $from) !== FALSE) {
                             $state = 5;
                         } else {
                             $state = 1;
                         }
                         //Show only in sent folder
                     }
                 }
             }
         }
         if (!isset($parsedMail['Subject'])) {
             $parsedMail['Subject'] = '';
         }
         $mail = new MailContent();
         $mail->setAccountId($account->getId());
         $mail->setState($state);
//.........这里部分代码省略.........
开发者ID:abhinay100,项目名称:fengoffice_app,代码行数:101,代码来源:MailUtilities.class.php

示例5: replicateRepetitiveTaskForCalendarRawTask

function replicateRepetitiveTaskForCalendarRawTask($task, $from_date, $to_date)
{
    $new_task_array = array();
    if ($task['repeat_forever'] > 0 || $task['repeat_num'] > 0 || $task['repeat_end'] != EMPTY_DATETIME) {
        $res = forwardRepDateRawTask($task, $from_date);
        $ref_date = $res['date'];
        $top_repeat_num = $task['repeat_num'] - $res['count'];
        $last_repeat = $task['repeat_end'] != EMPTY_DATETIME ? new DateTimeValue(strtotime($task['repeat_end'])) : null;
        if ($task['repeat_num'] > 0 && $top_repeat_num <= 0 || $last_repeat instanceof DateTimeValue && $last_repeat->getTimestamp() < $ref_date->getTimestamp()) {
            return array();
        }
        $num_repetitions = 0;
        while ($ref_date->getTimestamp() < $to_date->getTimestamp()) {
            if ($task['repeat_by'] == 'start_date' && $task['start_date'] == EMPTY_DATETIME) {
                return $new_task_array;
            }
            if ($task['repeat_by'] == 'due_date' && $task['due_date'] == EMPTY_DATETIME) {
                return $new_task_array;
            }
            if ($task['repeat_by'] == 'start_date') {
                $diff = $ref_date->getTimestamp() - strtotime($task['start_date']);
                $task['start_date'] = $ref_date->toMySQL();
                if ($task['due_date'] != EMPTY_DATETIME) {
                    $dd = new DateTimeValue(strtotime($task['due_date']));
                    $dd->advance($diff);
                    $task['due_date'] = $dd->toMySQL();
                }
            } else {
                if ($task['repeat_by'] == 'due_date') {
                    $diff = $ref_date->getTimestamp() - strtotime($task['due_date']);
                    $task['due_date'] = $ref_date->toMySQL();
                    if ($task['start_date'] != EMPTY_DATETIME) {
                        $sd = new DateTimeValue(strtotime($task['start_date']));
                        $sd->advance($diff);
                        $task['start_date'] = $sd->toMySQL();
                    }
                }
            }
            $new_task = array();
            foreach ($task as $k => $v) {
                $new_task[$k] = $v;
            }
            $new_due_date = null;
            $new_st_date = null;
            if ($task['start_date'] != EMPTY_DATETIME) {
                $new_st_date = new DateTimeValue(strtotime($task['start_date']));
            }
            if ($task['due_date'] != EMPTY_DATETIME) {
                $new_due_date = new DateTimeValue(strtotime($task['due_date']));
            }
            if ($task['repeat_d'] > 0) {
                if ($new_st_date instanceof DateTimeValue) {
                    $new_st_date = $new_st_date->add('d', $task['repeat_d']);
                }
                if ($new_due_date instanceof DateTimeValue) {
                    $new_due_date = $new_due_date->add('d', $task['repeat_d']);
                }
                $ref_date->add('d', $task['repeat_d']);
            } else {
                if ($task['repeat_m'] > 0) {
                    if ($new_st_date instanceof DateTimeValue) {
                        $new_st_date = $new_st_date->add('M', $task['repeat_m']);
                    }
                    if ($new_due_date instanceof DateTimeValue) {
                        $new_due_date = $new_due_date->add('M', $task['repeat_m']);
                    }
                    $ref_date->add('M', $task['repeat_m']);
                } else {
                    if ($task['repeat_y'] > 0) {
                        if ($new_st_date instanceof DateTimeValue) {
                            $new_st_date = $new_st_date->add('y', $task['repeat_y']);
                        }
                        if ($new_due_date instanceof DateTimeValue) {
                            $new_due_date = $new_due_date->add('y', $task['repeat_y']);
                        }
                        $ref_date->add('y', $task['repeat_y']);
                    }
                }
            }
            if ($new_st_date instanceof DateTimeValue) {
                $new_task['start_date'] = $new_st_date->toMySQL();
            }
            if ($new_due_date instanceof DateTimeValue) {
                $new_task['due_date'] = $new_due_date->toMySQL();
            }
            $num_repetitions++;
            if ($top_repeat_num > 0 && $top_repeat_num == $num_repetitions) {
                break;
            }
            if ($last_repeat instanceof DateTimeValue && $last_repeat->getTimestamp() < $ref_date->getTimestamp()) {
                break;
            }
            $new_task_array[] = $new_task;
            $task = array();
            foreach ($new_task as $k => $v) {
                $task[$k] = $v;
            }
        }
    } else {
        return array($task);
//.........这里部分代码省略.........
开发者ID:abhinay100,项目名称:feng_app,代码行数:101,代码来源:calendar.php

示例6: array


//.........这里部分代码省略.........
         if ($success && $check == 0) {
             return;
         }
     }
     $reminders = ObjectReminders::getDueReminders("reminder_popup");
     $popups = array();
     foreach ($reminders as $reminder) {
         $context = $reminder->getContext();
         if (str_starts_with($context, "mails_in_outbox")) {
             if ($reminder->getUserId() > 0 && $reminder->getUserId() != logged_user()->getId()) {
                 continue;
             }
             preg_match('!\\d+!', $context, $matches);
             evt_add("popup", array('title' => lang("mails_in_outbox reminder"), 'message' => lang("mails_in_outbox reminder desc", $matches[0]), 'type' => 'reminder', 'sound' => 'info'));
             $reminder->delete();
             continue;
         }
         if (str_starts_with($context, "eauthfail")) {
             if ($reminder->getUserId() == logged_user()->getId()) {
                 $acc = trim(substr($context, strrpos($context, " ")));
                 evt_add("popup", array('title' => lang("failed to authenticate email account"), 'message' => lang("failed to authenticate email account desc", $acc), 'type' => 'reminder', 'sound' => 'info'));
                 $reminder->delete();
             }
             continue;
         }
         $object = $reminder->getObject();
         $type = $object->getObjectTypeName();
         $date = $object->getColumnValue($reminder->getContext());
         if (!$date instanceof DateTimeValue) {
             continue;
         }
         if ($object->isTrashed()) {
             $reminder->delete();
             continue;
         }
         // convert time to the user's locale
         $timezone = logged_user()->getTimezone();
         if ($date->getTimestamp() + 5 * 60 < DateTimeValueLib::now()->getTimestamp()) {
             // don't show popups older than 5 minutes
             //$reminder->delete();
             //continue;
         }
         if ($reminder->getUserId() == 0) {
             if (!$object->isSubscriber(logged_user())) {
                 // reminder for subscribers and user is not subscriber
                 continue;
             }
         } else {
             if ($reminder->getUserId() != logged_user()->getId()) {
                 continue;
             }
         }
         if ($context == "due_date" && $object instanceof ProjectTask) {
             if ($object->isCompleted()) {
                 // don't show popups for completed tasks
                 $reminder->delete();
                 continue;
             }
         }
         $url = $object->getViewUrl();
         $link = '<a href="#" onclick="og.openLink(\'' . $url . '\');return false;">' . clean($object->getObjectName()) . '</a>';
         evt_add("popup", array('title' => lang("{$context} {$type} reminder", clean($object->getObjectName())), 'message' => lang("{$context} {$type} reminder desc", $link, format_datetime($date)), 'type' => 'reminder', 'sound' => 'info'));
         if ($reminder->getUserId() == 0) {
             // reminder is for all subscribers, so change it for one reminder per user (except logged_user)
             // otherwise if deleted it won't notify other subscribers and if not deleted it will keep notifying
             // logged user
             $subscribers = $object->getSubscribers();
             foreach ($subscribers as $subscriber) {
                 if ($subscriber->getId() != logged_user()->getId()) {
                     $new = new ObjectReminder();
                     $new->setContext($reminder->getContext());
                     $new->setDate($reminder->getDate());
                     $new->setMinutesBefore($reminder->getMinutesBefore());
                     $new->setObject($object);
                     $new->setUser($subscriber);
                     $new->setType($reminder->getType());
                     $new->save();
                 }
             }
         }
         $reminder->delete();
     }
     // popup reminders already checked for logged user
     if (GlobalCache::isAvailable()) {
         $today_next_reminders = ObjectReminders::findAll(array('conditions' => array("`date` > ? AND `date` < ?", DateTimeValueLib::now(), DateTimeValueLib::now()->endOfDay()), 'limit' => config_option('cron reminder limit', 100)));
         if (count($today_next_reminders) == 0) {
             GlobalCache::update('check_for_popup_reminders_' . logged_user()->getId(), 0, 60 * 30);
         }
     }
     // check for member modifications
     if (isset($_POST['dims_check_date'])) {
         $dims_check_date = new DateTimeValue($_POST['dims_check_date']);
         $dims_check_date_sql = $dims_check_date->toMySQL();
         $members_log_count = ApplicationLogs::instance()->count("member_id>0 AND created_on>'{$dims_check_date_sql}'");
         if ($members_log_count > 0) {
             $extra_data['reload_dims'] = 1;
         }
     }
     ajx_extra_data($extra_data);
 }
开发者ID:abhinay100,项目名称:feng_app,代码行数:101,代码来源:ObjectController.class.php


注:本文中的DateTimeValue::toMySQL方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。