本文整理汇总了PHP中SugarDateTime::asDb方法的典型用法代码示例。如果您正苦于以下问题:PHP SugarDateTime::asDb方法的具体用法?PHP SugarDateTime::asDb怎么用?PHP SugarDateTime::asDb使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SugarDateTime
的用法示例。
在下文中一共展示了SugarDateTime::asDb方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAgenda
public function getAgenda($api, $args)
{
// Fetch the next 14 days worth of meetings (limited to 20)
$end_time = new SugarDateTime("+14 days");
$start_time = new SugarDateTime("-1 hour");
$meeting = BeanFactory::newBean('Meetings');
$meetingList = $meeting->get_list('date_start', "date_start > " . $GLOBALS['db']->convert($GLOBALS['db']->quoted($start_time->asDb()), 'datetime') . " AND date_start < " . $GLOBALS['db']->convert($GLOBALS['db']->quoted($end_time->asDb()), 'datetime'));
// Setup the breaks for the various time periods
$datetime = new SugarDateTime();
$today_stamp = $datetime->get_day_end()->getTimestamp();
$tomorrow_stamp = $datetime->setDate($datetime->year, $datetime->month, $datetime->day + 1)->get_day_end()->getTimestamp();
$timeDate = TimeDate::getInstance();
$returnedMeetings = array('today' => array(), 'tomorrow' => array(), 'upcoming' => array());
foreach ($meetingList['list'] as $meetingBean) {
$meetingStamp = $timeDate->fromUser($meetingBean->date_start)->getTimestamp();
$meetingData = $this->formatBean($api, $args, $meetingBean);
if ($meetingStamp < $today_stamp) {
$returnedMeetings['today'][] = $meetingData;
} else {
if ($meetingStamp < $tomorrow_stamp) {
$returnedMeetings['tomorrow'][] = $meetingData;
} else {
$returnedMeetings['upcoming'][] = $meetingData;
}
}
}
return $returnedMeetings;
}
示例2: getRecentlyViewedQueryObject
/**
* Returns query object to retrieve list of recently viewed records by
* module.
*
* @param SugarBean $seed Instance of current bean.
* @param array $options Prepared options.
* @return SugarQuery query to execute.
*/
protected function getRecentlyViewedQueryObject($seed, $options)
{
$currentUser = $this->getUserBean();
$query = new SugarQuery();
$query->from($seed);
// FIXME: FRM-226, logic for these needs to be moved to SugarQuery
// Since tracker relationships don't actually exist, we're gonna have to add a direct join
$query->joinRaw(sprintf(" JOIN tracker ON tracker.item_id=%s.id AND tracker.module_name='%s' AND tracker.user_id='%s' ", $query->from->getTableName(), $query->from->module_name, $currentUser->id), array('alias' => 'tracker'));
// we need to set the linkName to hack around tracker not having real relationships
/* TODO think about how to fix this so we can be less restrictive to raw joins that don't have a relationship */
$query->join['tracker']->linkName = 'tracker';
$query->select(array('id', array('tracker.module_name', 'module_name')));
if (!empty($options['date'])) {
$td = new SugarDateTime();
$td->modify($options['date']);
$query->where()->queryAnd()->gte('tracker.date_modified', $td->asDb());
}
foreach ($query->select()->select as $v) {
$query->groupBy($v->table . '.' . $v->field);
}
$query->select()->fieldRaw('MAX(tracker.date_modified)', 'last_viewed_date');
return $query;
}
示例3: addTrackerFilter
protected static function addTrackerFilter(SugarQuery $q, SugarQuery_Builder_Where $where, $interval)
{
global $db;
$td = new SugarDateTime();
$td->modify($interval);
$min_date = $td->asDb();
// Have to do a subselect because MAX() and GROUP BY don't get along with
// databases other than MySQL
$q->joinRaw(" INNER JOIN ( SELECT t.item_id item_id, MAX(t.date_modified) track_max " . " FROM tracker t " . " WHERE t.module_name = '" . $db->quote($q->from->module_name) . "' " . " AND t.user_id = '" . $db->quote($GLOBALS['current_user']->id) . "' " . " AND t.date_modified >= " . $db->convert("'" . $min_date . "'", 'datetime') . " " . " GROUP BY t.item_id " . " ) tracker ON tracker.item_id = " . $q->from->getTableName() . ".id ", array('alias' => 'tracker'));
// Now, if they want tracker records, so let's order it by the tracker date_modified
$q->order_by = array();
$q->orderByRaw('tracker.track_max', 'DESC');
$q->distinct(false);
}
示例4: formatDate
/**
* Formats a DateTime object as string for given widget
*
* @param SugarDateTime $date - Date to be formatted for widget
* @return string date formatted for widget type
*/
protected function formatDate($date)
{
return $date->asDb();
}