本文整理汇总了PHP中JDate::toSql方法的典型用法代码示例。如果您正苦于以下问题:PHP JDate::toSql方法的具体用法?PHP JDate::toSql怎么用?PHP JDate::toSql使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JDate
的用法示例。
在下文中一共展示了JDate::toSql方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadByIP
public function loadByIP($ip, $mode = self::ACTIVE)
{
// Reset the table.
$k = $this->_tbl_key;
$this->{$k} = 0;
$this->reset();
// Check for a valid id to load.
if ($ip === null || !is_string($ip)) {
return false;
}
$now = new JDate();
// Load the user data.
$query = "SELECT * FROM {$this->_tbl}\n\t\t\tWHERE ip = {$this->_db->quote($ip)}\n\t\t\t" . ($mode == self::ACTIVE ? "AND (expiration = {$this->_db->quote($this->_db->getNullDate())} OR expiration > {$this->_db->quote($now->toSql())})" : '') . "\n\t\t\tORDER BY id DESC";
$this->_db->setQuery($query, 0, 1);
$data = $this->_db->loadAssoc();
// Check for an error message.
if ($this->_db->getErrorNum()) {
$this->setError($this->_db->getErrorMsg());
return false;
}
if (empty($data)) {
$this->ip = $ip;
return false;
}
// Bind the data to the table.
$this->bind($data);
return true;
}
示例2: getList
public static function getList(&$params)
{
$db = JFactory::getDbo();
$user = JFactory::getUser();
$groups = implode(',', $user->getAuthorisedViewLevels());
$timeframe = $params->get('timeframe', 'alltime');
$maximum = $params->get('maximum', 5);
$order_value = $params->get('order_value', 'count');
if ($order_value == 'rand()') {
$order_direction = '';
} else {
$order_value = $db->quoteName($order_value);
$order_direction = $params->get('order_direction', 1) ? 'DESC' : 'ASC';
}
$query = $db->getQuery(true)->select(array('MAX(' . $db->quoteName('tag_id') . ') AS tag_id', ' COUNT(*) AS count', 'MAX(t.title) AS title', 'MAX(' . $db->quoteName('t.access') . ') AS access', 'MAX(' . $db->quoteName('t.alias') . ') AS alias'))->group($db->quoteName(array('tag_id', 'title', 'access', 'alias')))->from($db->quoteName('#__contentitem_tag_map'))->where($db->quoteName('t.access') . ' IN (' . $groups . ')');
// Only return published tags
$query->where($db->quoteName('t.published') . ' = 1 ');
// Optionally filter on language
$language = JComponentHelper::getParams('com_tags')->get('tag_list_language_filter', 'all');
if ($language != 'all') {
if ($language == 'current_language') {
$language = JHelperContent::getCurrentLanguage();
}
$query->where($db->quoteName('t.language') . ' IN (' . $db->quote($language) . ', ' . $db->quote('*') . ')');
}
if ($timeframe != 'alltime') {
$now = new JDate();
$query->where($db->quoteName('tag_date') . ' > ' . $query->dateAdd($now->toSql('date'), '-1', strtoupper($timeframe)));
}
$query->join('INNER', $db->quoteName('#__tags', 't') . ' ON ' . $db->quoteName('tag_id') . ' = t.id')->order($order_value . ' ' . $order_direction);
$db->setQuery($query, 0, $maximum);
$results = $db->loadObjectList();
return $results;
}
示例3: stdClass
function &getData()
{
if (empty($this->_data)) {
$query = ' SELECT * FROM #__fst_comments ' . ' WHERE id = ' . FSTJ3Helper::getEscaped($this->_db, $this->_id);
$this->_db->setQuery($query);
$this->_data = $this->_db->loadObject();
}
if (!$this->_data) {
$this->_data = new stdClass();
$this->_data->id = 0;
$this->_data->ident = 5;
//
$this->_data->itemid = 0;
$this->_data->body = null;
$this->_data->email = null;
$this->_data->name = null;
$this->_data->website = null;
$this->_data->published = 1;
$current_date = new JDate();
if (FSTJ3Helper::IsJ3()) {
$mySQL_conform_date = $current_date->toSql();
} else {
$mySQL_conform_date = $current_date->toMySQL();
}
$this->_data->created = $mySQL_conform_date;
}
return $this->_data;
}
示例4: migrate
protected function migrate($row)
{
$nd = $this->_db->getNullDate();
$obj = new stdClass();
$obj->id = $row->id;
$obj->task_title = $row->title;
$obj->description = $row->content;
$obj->created_by = $row->user_id;
$obj->state = $row->state;
$obj->access = $row->access ? $row->access : $this->access;
$obj->project_id = $row->project_id;
$obj->task_id = $row->task_id;
$obj->billable = 1;
// Set creation date
if ($row->cdate) {
$date = new JDate($row->cdate);
$obj->created = $date->toSql();
$obj->log_date = $obj->created;
}
// Set attribs
$obj->attribs = '{}';
// Set log time
$obj->log_time = $row->timelog > 0 ? $row->timelog * 60 : 1;
// Store base item
if (!$this->_db->insertObject('#__pf_timesheet', $obj)) {
$this->success = false;
$this->log[] = $this->_db->getError();
return false;
}
// Create asset
$nulls = false;
$parent = $this->getParentAsset();
$asset = JTable::getInstance('Asset', 'JTable', array('dbo' => $this->_db));
$asset->loadByName('com_pftime.time.' . $row->id);
// Check for an error.
if ($error = $asset->getError()) {
$this->log[] = $error;
} else {
if (empty($asset->id)) {
$asset->setLocation($parent, 'last-child');
}
// Prepare the asset to be stored.
$asset->parent_id = $parent;
$asset->name = 'com_pftime.time.' . $row->id;
$asset->title = $row->title;
$asset->rules = '{}';
if (!$asset->check() || !$asset->store($nulls)) {
$this->log[] = $asset->getError();
} else {
$query = $this->_db->getQuery(true);
$query->update('#__pf_timesheet')->set('asset_id = ' . (int) $asset->id)->where('id = ' . (int) $row->id);
$this->_db->setQuery($query);
if (!$this->_db->execute()) {
$this->log[] = JText::sprintf('JLIB_DATABASE_ERROR_STORE_FAILED_UPDATE_ASSET_ID', $this->_db->getErrorMsg());
}
}
}
return true;
}
示例5: check
public function check()
{
$date = new JDate($this->date_from);
$this->date_from = $date->toSql();
$date1 = new JDate($this->date_to);
$this->date_to = $date1->toSql();
return parent::check();
}
示例6: PurgeExpiredSessions
private function PurgeExpiredSessions()
{
$lifetime = JFactory::getConfig()->get("lifetime", DEFAULT_SESSION_LIFETIME);
$date = new JDate("-" . $lifetime . " minute");
$sql = "DELETE FROM #__" . $GLOBALS["ext_name"] . "_sessions WHERE birth < '" . $date->toSql() . "';";
$this->db->setQuery($sql);
$this->db->query();
}
示例7: store
/**
* Method to store the item
*
* @package MageBridge
* @access public
* @param array $data
* @return bool
*/
public function store($data)
{
// Prepare the data
$now = new JDate('now');
// Build the data
$data['remote_addr'] = $_SERVER['REMOTE_ADDR'];
$data['http_agent'] = $_SERVER['HTTP_USER_AGENT'];
$data['timestamp'] = $now->toSql();
return parent::store($data);
}
示例8: log
public static function log($action, $user_id = null)
{
$table = JTable::getInstance('', 'CTableEngagement');
$table->action = $action;
$table->user_id = $user_id;
$date = new JDate();
$table->created = $date->toSql();
$table->week = $date->format('W');
$table->store();
}
示例9: load
/**
* Load data about the most funded projects.
*
* <code>
* $mostFunded = new Crowdfunding\Statistics\Projects\MostFunded(\JFactory::getDbo());
* $mostFunded->load();
*
* foreach ($mostFunded as $project) {
* echo $project["title"];
* }
* </code>
*
* @param int $limit Number of result that will be loaded.
*/
public function load($limit = 5)
{
// Get current date
jimport('joomla.date.date');
$date = new \JDate();
$today = $date->toSql();
$query = $this->getQuery();
$query->where('( a.published = 1 AND a.approved = 1 )')->where('( a.funding_start <= ' . $this->db->quote($today) . ' AND a.funding_end >= ' . $this->db->quote($today) . ' )')->order('a.funded DESC');
$this->db->setQuery($query, 0, (int) $limit);
$this->items = (array) $this->db->loadAssocList();
}
示例10: onAfterParseData
public function onAfterParseData($params)
{
$db = JFactory::getDbo();
$table = new JTableJed($db);
$table->load(array('md5url' => md5($params->get('url'))));
$lastUpdate = new JDate($params->get('data.last_update'));
$dateAdded = new JDate($params->get('data.date_added'));
$today = new JDate();
$table->url = $params->get('url');
$table->md5url = md5($table->url);
$table->title = $params->get('data.title', '');
$table->alias = JApplication::stringURLSafe($table->title);
$table->fulltext = $params->get('data.description', '');
$table->introtext = $this->getIntrotext($table->fulltext);
$table->catid = $this->getCategory($params);
$table->avatar = $this->getAvatar($params);
$table->gallery = $this->getGallery($params);
$table->featured = $params->get('data.feature', '') == '' ? false : true;
$table->popular = $params->get('data.popular', '') == '' ? false : true;
$table->component = $params->get('data.component', '') == '' ? false : true;
$table->module = $params->get('data.module', '') == '' ? false : true;
$table->plugin = $params->get('data.plugin', '') == '' ? false : true;
$table->language = $params->get('data.language', '') == '' ? false : true;
$table->specific = $params->get('data.specific', '') == '' ? false : true;
$table->compat_15 = $params->get('data.compat_15', '') == '' ? false : true;
$table->compat_25 = $params->get('data.compat_25', '') == '' ? false : true;
$table->compat_30 = $params->get('data.compat_30', '') == '' ? false : true;
$table->version = $params->get('data.version', '');
$table->date_added = $dateAdded->toSql();
$table->last_update = $lastUpdate->toSql();
$table->rating = $params->get('data.rating', 0);
$table->rating_count = $params->get('data.rating_user', 0);
$table->rating_sum = round($table->rating * $table->rating_count);
$table->favorite = $params->get('data.favorite', 0);
$table->license = $params->get('data.license', '');
$table->view = $params->get('data.view', 0);
$table->developer = $params->get('data.developer', '');
$table->website = $this->getRedirectUrl($params->get('data.website'));
$table->download_url = $params->get('data.download_link');
$table->demo_url = $params->get('data.demo_link');
$table->support_url = $params->get('data.support_link');
$table->document_url = $params->get('data.document_link');
$time = $today->toUnix() - $dateAdded->toUnix();
$days = $time / (60 * 60 * 24) + 1;
$table->ordering = floor($table->view / $days);
if (!$table->id) {
$table->state = 1;
}
//print_r($params);
//print_r($table);die();
if ($table->store()) {
$params->set('success', true);
}
}
示例11: load
/**
* Load data about the most funded projects.
*
* <code>
* $popular = new CrowdfundingStatisticsProjectsPopular(JFactory::getDbo());
* $popular->load();
*
* foreach ($popular as $project) {
* echo $project["title"];
* echo $project["hits"];
* }
* </code>
*
* @param int $limit Number of result that will be loaded.
*/
public function load($limit = 5)
{
// Get current date
jimport("joomla.date.date");
$date = new \JDate();
$today = $date->toSql();
$query = $this->getQuery();
$query->where("( a.published = 1 AND a.approved = 1 )")->where("( a.funding_start <= " . $this->db->quote($today) . " AND a.funding_end >= " . $this->db->quote($today) . " )")->order("a.hits DESC");
$this->db->setQuery($query, 0, (int) $limit);
$this->items = (array) $this->db->loadAssocList();
}
示例12: load
/**
* Load data about the most funded projects.
*
* <code>
* $popular = new Crowdfunding\Statistics\Projects\Popular(JFactory::getDbo());
* $popular->load(['limit' => 5]);
*
* foreach ($popular as $project) {
* echo $project["title"];
* echo $project["hits"];
* }
* </code>
*
* @param array $options
*/
public function load(array $options = array())
{
$limit = ArrayHelper::getValue($options, 'limit', 5, 'int');
// Get current date
jimport('joomla.date.date');
$date = new \JDate();
$today = $date->toSql();
$query = $this->getQuery();
$query->where('( a.published = 1 AND a.approved = 1 )')->where('( a.funding_start <= ' . $this->db->quote($today) . ' AND a.funding_end >= ' . $this->db->quote($today) . ' )')->order('a.hits DESC');
$this->db->setQuery($query, 0, (int) $limit);
$this->items = (array) $this->db->loadAssocList();
}
示例13: store
public function store($updateNulls = false)
{
$date = new JDate();
$this->created = $date->toSql(true);
$result = parent::store();
if ($result) {
// Update tag words count
$word = JTable::getInstance('Tagword', 'CTable');
$word->load($this->tag);
$word->update();
}
return $result;
}
示例14: check
function check()
{
// make published by default and get a new order no
if (!$this->id) {
if ($this->created == "") {
$current_date = new JDate();
if (FSSJ3Helper::IsJ3()) {
$mySQL_conform_date = $current_date->toSql();
} else {
$mySQL_conform_date = $current_date->toMySQL();
}
$this->set('created', $mySQL_conform_date);
}
}
return true;
}
示例15: send
/**
* Store a notification to database.
*
* <code>
* $userId = 1;
* $content = "....";
*
* $notification = new Prism\Integration\Notification\EasySocial($userId, $content);
* $notification->setDb(JFactory::getDbo());
*
* $notification->send();
* </code>
*
* @param string $content
*/
public function send($content = '')
{
if ($content !== '') {
$this->content = $content;
}
$query = $this->db->getQuery(true);
$date = new \JDate();
$query->insert($this->db->quoteName('#__social_notifications'))->set($this->db->quoteName('uid') . '=' . (int) $this->uid)->set($this->db->quoteName('actor_id') . '=' . (int) $this->actorId)->set($this->db->quoteName('actor_type') . '=' . $this->db->quote($this->actorType))->set($this->db->quoteName('target_id') . '=' . (int) $this->targetId)->set($this->db->quoteName('target_type') . '=' . $this->db->quote($this->targetType))->set($this->db->quoteName('content') . '=' . $this->db->quote($this->content))->set($this->db->quoteName('cmd') . '=' . $this->db->quote($this->cmd))->set($this->db->quoteName('type') . '=' . $this->db->quote($this->type))->set($this->db->quoteName('url') . '=' . $this->db->quote($this->url))->set($this->db->quoteName('state') . '=' . (int) $this->state)->set($this->db->quoteName('created') . '=' . $this->db->quote($date->toSql()));
if ($this->image !== null) {
$query->set($this->db->quoteName('image') . '=' . $this->db->quote($this->image));
}
if ($this->title !== null) {
$query->set($this->db->quoteName('title') . '=' . $this->db->quote($this->title));
}
$this->db->setQuery($query);
$this->db->execute();
$this->id = $this->db->insertid();
}