本文整理汇总了PHP中JDate::toMySQL方法的典型用法代码示例。如果您正苦于以下问题:PHP JDate::toMySQL方法的具体用法?PHP JDate::toMySQL怎么用?PHP JDate::toMySQL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JDate
的用法示例。
在下文中一共展示了JDate::toMySQL方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
*
*/
public function store($preventUpdate = false)
{
// Set date if none exist
if ($preventUpdate != true) {
$now = new JDate();
$this->created = $now->toMySQL();
$this->updated = $now->toMySQL();
}
return parent::store();
}
示例2: savePayment
function savePayment()
{
$orderid = JRequest::getVar('orderid');
$Itemid = JRequest::getVar('Itemid');
$order = JTable::getInstance('OrdersTable', 'JTheFactory');
if (!$order->load($orderid)) {
$app = JFactory::getApplication();
$app->redirect('index.php?option=' . APP_EXTENSION . '&Itemid=' . $Itemid, JText::_("FACTORY_ORDER_DOES_NOT_EXIST"));
return;
}
$paylog = JTable::getInstance('PaymentLogTable', 'JTheFactory');
$date = new JDate();
$paylog->date = $date->toMySQL();
$paylog->amount = $order->order_total;
$paylog->currency = $order->order_currency;
$paylog->refnumber = JRequest::getVar('customer_note');
$paylog->invoice = $orderid;
$paylog->ipn_response = print_r($_REQUEST, true);
$paylog->ipn_ip = $_SERVER['REMOTE_ADDR'];
$paylog->status = 'manual_check';
$paylog->userid = $order->userid;
$paylog->orderid = $order->id;
$paylog->payment_method = $this->name;
$paylog->store();
$order->paylogid = $paylog->id;
$order->store();
}
示例3: processIPN
function processIPN()
{
$model = JModel::getInstance('Gateways', 'JTheFactoryModel');
$params = $model->loadGatewayParams($this->name);
$test_mode = $params->get('test_mode', 0);
$x_login = $params->get('x_login', '');
$paylog = JTable::getInstance('PaymentLogTable', 'JTheFactory');
$date = new JDate();
$paylog->date = $date->toMySQL();
$paylog->amount = JRequest::getVar('x_amount');
$paylog->currency = '';
//JRequest::getVar('');
$paylog->refnumber = JRequest::getVar('x_trans_id');
$paylog->invoice = JRequest::getVar('x_invoice_num');
$paylog->ipn_response = print_r($_REQUEST, true);
$paylog->ipn_ip = $_SERVER['REMOTE_ADDR'];
$paylog->status = 'error';
$paylog->userid = null;
$paylog->orderid = JRequest::getVar('x_invoice_num');
$paylog->payment_method = $this->name;
$receiver_email = JRequest::getVar('receiver_email');
$payment_status = JRequest::getVar('x_2checked');
if ($payment_status == 'Y') {
$paylog->status = 'ok';
} else {
$paylog->status = 'error';
}
$paylog->store();
return $paylog;
}
示例4: store
public function store()
{
$now = new JDate();
// Always update the stream last updated time
$this->updated = $now->toMySQL();
return parent::store();
}
示例5: getList
function getList(&$params)
{
global $mainframe;
$db =& JFactory::getDBO();
$user =& JFactory::getUser();
$userId = (int) $user->get('id');
$count = (int) $params->get('count', 5);
$catid = trim($params->get('catid'));
$secid = trim($params->get('secid'));
$show_front = $params->get('show_front', 1);
$aid = $user->get('aid', 0);
$contentConfig =& JComponentHelper::getParams('com_content');
$access = !$contentConfig->get('shownoauth');
$nullDate = $db->getNullDate();
jimport('joomla.utilities.date');
$date = new JDate();
$now = $date->toMySQL();
$where = 'a.state = 1' . ' AND ( a.publish_up = ' . $db->Quote($nullDate) . ' OR a.publish_up <= ' . $db->Quote($now) . ' )' . ' AND ( a.publish_down = ' . $db->Quote($nullDate) . ' OR a.publish_down >= ' . $db->Quote($now) . ' )';
// User Filter
switch ($params->get('user_id')) {
case 'by_me':
$where .= ' AND (created_by = ' . (int) $userId . ' OR modified_by = ' . (int) $userId . ')';
break;
case 'not_me':
$where .= ' AND (created_by <> ' . (int) $userId . ' AND modified_by <> ' . (int) $userId . ')';
break;
}
// Ordering
switch ($params->get('ordering')) {
case 'm_dsc':
$ordering = 'a.modified DESC, a.created DESC';
break;
case 'c_dsc':
default:
$ordering = 'a.created DESC';
break;
}
if ($catid) {
$ids = explode(',', $catid);
JArrayHelper::toInteger($ids);
$catCondition = ' AND (cc.id=' . implode(' OR cc.id=', $ids) . ')';
}
if ($secid) {
$ids = explode(',', $secid);
JArrayHelper::toInteger($ids);
$secCondition = ' AND (s.id=' . implode(' OR s.id=', $ids) . ')';
}
// Content Items only
$query = 'SELECT a.*, ' . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END as slug,' . ' CASE WHEN CHAR_LENGTH(cc.alias) THEN CONCAT_WS(":", cc.id, cc.alias) ELSE cc.id END as catslug' . ' FROM #__content AS a' . ($show_front == '0' ? ' LEFT JOIN #__content_frontpage AS f ON f.content_id = a.id' : '') . ' INNER JOIN #__categories AS cc ON cc.id = a.catid' . ' INNER JOIN #__sections AS s ON s.id = a.sectionid' . ' WHERE ' . $where . ' AND s.id > 0' . ($access ? ' AND a.access <= ' . (int) $aid . ' AND cc.access <= ' . (int) $aid . ' AND s.access <= ' . (int) $aid : '') . ($catid ? $catCondition : '') . ($secid ? $secCondition : '') . ($show_front == '0' ? ' AND f.content_id IS NULL ' : '') . ' AND s.published = 1' . ' AND cc.published = 1' . ' ORDER BY ' . $ordering;
$db->setQuery($query, 0, $count);
$rows = $db->loadObjectList();
$i = 0;
$lists = array();
foreach ($rows as $row) {
$lists[$i]->link = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catslug, $row->sectionid));
$lists[$i]->text = htmlspecialchars($row->title);
$i++;
}
return $lists;
}
示例6: apply
function apply()
{
JRequest::checkToken() or jexit('Invalid Token');
$applicant = JRequest::get('POST');
jimport('joomla.utilities.date');
$now = new JDate();
if ($applicant['job_id'] != 0) {
$unsol_id = $applicant['id'];
$applicant['id'] = false;
$applicant['request_date'] = $now->toMySQL();
$record =& JTable::getInstance('Applicant', 'Table');
if (!$record->save($applicant)) {
// uh oh failed to save
JError::raiseError('500', JTable::getError());
}
$unsol =& JTable::getInstance('Unsolicited', 'Table');
if (!$unsol->delete($unsol_id)) {
// uh oh failed to delete
JError::raiseError('500', JTable::getError());
}
$this->extendApply($applicant);
} else {
$applicant['last_updated'] = $now->toMySQL();
$unsol_record =& JTable::getInstance('Unsolicited', 'Table');
if (!$unsol_record->save($applicant)) {
// uh oh failed to save
JError::raiseError('500', JTable::getError());
}
$this->extendApply($applicant);
}
}
示例7: jimport
function __construct(&$_db)
{
parent::__construct('#__banner', 'bid', $_db);
jimport('joomla.utilities.date');
$now = new JDate();
$this->set('date', $now->toMySQL());
}
示例8: save
function save($data)
{
$row =& JTable::getInstance('Articles', 'Table');
$id = $data['id'];
if (!$id) {
jimport('joomla.utilities.date');
$dateNow = new JDate();
$dateMySql = $dateNow->toMySQL();
$data['createdate'] = $dateMySql;
$data['addedby'] = 'server';
$data['author'] = 'Administrator';
}
if (!$row->bind($data)) {
JError::raiseError(500, $row->getError());
return false;
}
if (!$row->check()) {
JError::raiseError(500, $row->getError());
}
if (!$row->store()) {
JError::raiseError(500, $row->getError());
return false;
}
return true;
}
示例9: save
function save($data)
{
$row =& JTable::getInstance('codefile', 'Table');
$id = $data['id'];
if (!$id) {
jimport('joomla.utilities.date');
$dateNow = new JDate();
$dateMySql = $dateNow->toMySQL();
$data['creationdate'] = $dateMySql;
$data['addedby'] = 'server';
}
if (!$row->bind($data)) {
JError::raiseError(500, $row->getError());
return false;
}
if (!$row->check()) {
JError::raiseError(500, $row->getError());
}
if (!$row->store()) {
JError::raiseError(500, $row->getError());
return false;
} else {
if (!$id) {
$row->load($row->{$id});
}
if ($_FILES['cfile']['size']) {
$this->fileupdload($row->id);
}
}
return true;
}
示例10: 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;
}
示例11: store
public function store($updateNulls = false)
{
$now = new JDate();
if ($this->created == null) {
$this->created = $now->toMySQL();
}
return parent::store($updateNulls);
}
示例12: store
public function store($updateNulls = false)
{
$now = new JDate();
if ($this->created == null) {
$this->created = $now->toMySQL();
}
$this->_generatePreview();
$this->params = $this->_params->toString();
return parent::store();
}
示例13: PurgeExpiredSessions
private function PurgeExpiredSessions()
{
//$app = JFactory::getApplication();
//global $app;
//$lifetime = $app->getCfg("lifetime");
$lifetime = JFactory::$config->get("lifetime");
$date = new JDate("-" . $lifetime . " minute");
$sql = "DELETE FROM #__" . $GLOBALS["ext_name"] . "_sessions WHERE birth < '" . $date->toMySQL() . "';";
$this->db->setQuery($sql);
$this->db->query();
}
示例14: getList
public function getList($params)
{
$db = JFactory::getDBO();
$user = JFactory::getUser();
$aid = $user->get('aid', 0);
$items = (int) $params->get('items', 0);
$order = $params->get('order', 'o_asc');
$noauth = !JComponentHelper::getParams('com_content')->get('shownoauth');
if (!($catid = $params->get('catid', 0))) {
return array();
}
$nullDate = $db->getNullDate();
jimport('joomla.utilities.date');
$date = new JDate();
$now = $date->toMySQL();
// Ordering
$direction = null;
switch ($params->get('order')) {
case 'random':
$ordering = 'RAND()';
break;
case 'date':
$ordering = 'a.created';
break;
case 'rdate':
$ordering = 'a.created DESC';
break;
case 'alpha':
$ordering = 'a.title';
break;
case 'ralpha':
$ordering = 'a.title DESC';
break;
case 'hits':
$ordering = 'a.hits';
break;
case 'rhits':
$ordering = 'a.hits DESC';
break;
case 'ordering':
default:
$ordering = 'a.ordering';
break;
}
$parts = explode(':', $catid);
$section = array_shift($parts);
$category = array_shift($parts);
// Query to determine article count
$query = 'SELECT a.*,' . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END as slug,' . ' CASE WHEN CHAR_LENGTH(cc.name) THEN CONCAT_WS(":", cc.id, cc.name) ELSE cc.id END as catslug' . ' FROM #__content AS a' . ' INNER JOIN #__categories AS cc ON cc.id = a.catid' . ' INNER JOIN #__sections AS s ON s.id = a.sectionid' . ' WHERE a.state = 1 ' . ($noauth ? ' AND a.access <= ' . (int) $aid . ' AND cc.access <= ' . (int) $aid . ' AND s.access <= ' . (int) $aid : '') . ' AND (a.publish_up = "' . $nullDate . '" OR a.publish_up <= "' . $now . '" ) ' . ' AND (a.publish_down = "' . $nullDate . '" OR a.publish_down >= "' . $now . '" )' . ($category ? ' AND cc.id = ' . (int) $category : '') . ' AND cc.section = ' . (int) $section . ' AND cc.published = 1' . ' AND s.published = 1' . ' ORDER BY ' . $ordering . ' LIMIT 0,' . (int) $items;
$db->setQuery($query);
return $db->loadObjectList();
}
示例15: loadChartData
function loadChartData()
{
$db = $this->getDBO();
$type = JRequest::getCmd('type');
switch ($type) {
case 'sales':
jimport('joomla.utilities.date');
$date = JFactory::getDate();
$interval = JRequest::getInt('interval', '14');
$today = $date->toFormat('%Y-%m-%d');
$startDate = strtotime('-' . $interval . ' day', strtotime($today));
$startDate = new JDate($startDate);
$query = "SELECT COUNT(virtuemart_order_id) AS sales, DATE(created_on) as `date` FROM #__virtuemart_orders WHERE created_on > " . $db->Quote($startDate->toMySQL()) . " GROUP BY `date` ORDER BY `date`";
$db->setQuery($query);
$rows = $db->loadObjectList();
$data = array();
foreach ($rows as $row) {
$data[$row->date] = (int) $row->sales;
}
$today = $date->toUnix();
for ($time = $startDate->toUnix(); $time <= $today; $time += 86400) {
$date = date('Y', $time) . '-' . date('m', $time) . '-' . date('d', $time);
if (!array_key_exists($date, $data)) {
$data[$date] = 0;
}
}
ksort($data);
$startYear = $startDate->toFormat('%Y');
$startMonth = $startDate->toFormat('%m') - 1;
$startDay = $startDate->toFormat('%d');
$script = "\r\n k2martSalesChartOptions.title.text = '" . JText::_('K2MART_TOTAL_SALES', true) . "';\r\n k2martSalesChartOptions.subtitle.text = '* " . JText::_('K2MART_CLICK_AND_DRAG_IN_THE_PLOT_AREA_TO_ZOOM_IN', true) . "';\r\n k2martSalesChartOptions.yAxis.title.text = '" . JText::_('K2MART_SALES', true) . "';\r\n k2martSalesChartOptions.series[0].pointStart=Date.UTC(" . $startYear . ", " . $startMonth . ", " . $startDay . "); \r\n k2martSalesChartOptions.series[0].data=[" . implode(',', $data) . "];\r\n ";
break;
case 'products':
$limit = JRequest::getInt('limit', '20');
$query = "SELECT product.product_sales, productData.product_name FROM #__virtuemart_products AS product \r\n LEFT JOIN #__virtuemart_products_" . VMLANG . " AS productData ON product.virtuemart_product_id = productData.virtuemart_product_id\r\n WHERE product.product_sales > 0 ORDER BY product.product_sales DESC LIMIT 0, {$limit}";
$db->setQuery($query);
$rows = $db->loadObjectList();
$data = array();
$categories = array();
foreach ($rows as $row) {
$data[] = (int) $row->product_sales;
$categories[] = "'" . $row->product_name . "'";
}
$script = "\r\n k2martProductsChartOptions.title.text = '" . JText::_('K2MART_TOP_SELLING_PRODUCTS', true) . "';\r\n k2martProductsChartOptions.yAxis.title.text = '" . JText::_('K2MART_SALES', true) . "';\r\n k2martProductsChartOptions.xAxis.categories =[" . implode(',', $categories) . "]; \r\n k2martProductsChartOptions.series[0].data=[" . implode(',', $data) . "];\r\n ";
break;
}
$script .= "k2martChartType = '{$type}';";
echo $script;
}