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


PHP JDate::toMysql方法代码示例

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


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

示例1: edit

	function edit() {
		$now = new JDate();
		$title = JRequest::getString ( "title", "" );
		$description = JRequest::getVar ( 'description', '', 'string', JREQUEST_ALLOWRAW );
		$sdescription = JRequest::getVar ( 'sdescription', '', 'string', JREQUEST_ALLOWRAW );
		$created = JRequest::getString ( "created", $now->toMysql() );
		if (!$created) $created = $now->toMysql();
		$published = JRequest::getInt ( "published", 1 );
		$showdate = JRequest::getInt ( "showdate", 1 );

		$id = $this->getState ( 'item.id' );
		if (!$id) {
			$query = "INSERT INTO #__kunena_announcement VALUES ('',
				{$this->db->Quote ( $title )},
				{$this->db->Quote ( $sdescription )},
				{$this->db->Quote ( $description )},
				{$this->db->Quote ( $created )},
				{$this->db->Quote ( $published )},
				0,
				{$this->db->Quote ( $showdate )})";
		} else {
			$query = "UPDATE #__kunena_announcement SET title={$this->db->Quote ( $title )},
				description={$this->db->Quote ( $description )},
				sdescription={$this->db->Quote ( $sdescription )},
				created={$this->db->Quote ( $created )},
				published={$this->db->Quote ( $published )},
				showdate={$this->db->Quote ( $showdate )}
				WHERE id=$id";
		}
		$this->db->setQuery ( $query );
		$this->db->query ();
		KunenaError::checkDatabaseError();
	}
开发者ID:GoremanX,项目名称:Kunena-2.0,代码行数:33,代码来源:announcement.php

示例2: 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->toMysql())})" : '') . "\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;
 }
开发者ID:laiello,项目名称:senluonirvana,代码行数:28,代码来源:kunenauserbans.php

示例3: edit

 function edit($id)
 {
     if (!$this->canEdit) {
         while (@ob_end_clean()) {
         }
         $this->app->redirect(CKunenaLink::GetKunenaURL(false), JText::_('COM_KUNENA_POST_NOT_MODERATOR'));
     }
     if ($this->tokenProtection()) {
         return false;
     }
     $now = new JDate();
     $title = JRequest::getVar("title", "");
     $description = JRequest::getVar('description', '', 'string', JREQUEST_ALLOWRAW);
     $sdescription = JRequest::getVar('sdescription', '', 'string', JREQUEST_ALLOWRAW);
     $created = JRequest::getVar("created", $now->toMysql());
     if (!$created) {
         $created = $now->toMysql();
     }
     $published = JRequest::getInt("published", 1);
     $showdate = JRequest::getInt("showdate", 1);
     if (!$id) {
         $query = "INSERT INTO #__kunena_announcement VALUES ('',\n\t\t\t\t{$this->db->Quote($title)},\n\t\t\t\t{$this->db->Quote($sdescription)},\n\t\t\t\t{$this->db->Quote($description)},\n\t\t\t\t{$this->db->Quote($created)},\n\t\t\t\t{$this->db->Quote($published)},\n\t\t\t\t0,\n\t\t\t\t{$this->db->Quote($showdate)})";
         $msg = JText::_('COM_KUNENA_ANN_SUCCESS_ADD');
     } else {
         $query = "UPDATE #__kunena_announcement SET title={$this->db->Quote($title)},\n\t\t\t\tdescription={$this->db->Quote($description)},\n\t\t\t\tsdescription={$this->db->Quote($sdescription)},\n\t\t\t\tcreated={$this->db->Quote($created)},\n\t\t\t\tpublished={$this->db->Quote($published)},\n\t\t\t\tshowdate={$this->db->Quote($showdate)}\n\t\t\t\tWHERE id={$id}";
         $msg = JText::_('COM_KUNENA_ANN_SUCCESS_EDIT');
     }
     $this->db->setQuery($query);
     if ($this->db->query()) {
         while (@ob_end_clean()) {
         }
         $this->app->redirect(CKunenaLink::GetAnnouncementURL('show', null, false), $msg);
     }
     if (KunenaError::checkDatabaseError()) {
         return;
     }
 }
开发者ID:vuchannguyen,项目名称:hoctap,代码行数:37,代码来源:kunena.announcement.class.php

示例4: check

 function check()
 {
     if (empty($this->file)) {
         $this->setError(JText::_('COM_MISSINGT_TABLE_HISTORY_FILE_REQUIRED'));
         return false;
     }
     if (empty($this->text)) {
         $this->setError(JText::_('COM_MISSINGT_TABLE_HISTORY_TEXT_REQUIRED'));
         return false;
     }
     if (empty($this->sha)) {
         $this->sha = sha1($this->text);
     }
     if (empty($this->last_modified)) {
         jimport('joomla.utilities.date');
         $date = new JDate();
         $this->last_modified = $date->toMysql();
     }
     if (!$this->modified_by) {
         $user =& JFactory::getUser();
         $this->modified_by = $user->get('id');
     }
     return true;
 }
开发者ID:julienV,项目名称:the-missing-T,代码行数:24,代码来源:history.php

示例5: save

	/**
	 * Method to save the KunenaUserBan object to the database
	 *
	 * @access	public
	 * @param	boolean $updateOnly Save the object only if not a new ban
	 * @return	boolean True on success
	 * @since 1.6
	 */
	public function save($updateOnly = false)
	{
		if (!$this->canBan()) {
			return false;
		}

		if (!$this->id) {
			// If we have new ban, add creation date and user if they do not exist
			if (!$this->created_time) {
				$now = new JDate();
				$this->created_time = $now->toMysql();
			}
			if (!$this->created_by) {
				$my = JFactory::getUser();
				$this->created_by = $my->id;
			}
		}

		// Create the user table object
		$table	= $this->getTable();
		$table->bind($this->getProperties());

		// Check and store the object.
		if (!$table->check()) {
			$this->setError($table->getError());
			return false;
		}

		//are we creating a new ban
		$isnew = !$this->_exists;

		// If we aren't allowed to create new ban, return
		if ($isnew && $updateOnly) {
			return true;
		}

		if ($this->userid) {
			// Change user block also in Joomla
			$user = JFactory::getUser($this->userid);
			if (!$user) {
				$this->setError("User {$this->userid} does not exist!");
				return false;
			}
			$block = 0;
			if ($this->isEnabled()) $block = $this->blocked;
			if ($user->block != $block) {
				$user->block = $block;
				$user->save();
			}

			// Change user state also in #__kunena_users
			$profile = KunenaFactory::getUser($this->userid);
			$profile->banned = $this->expiration;
			$profile->save(true);

			if ($block) {
				// Logout blocked user
				$app = JFactory::getApplication ();
				$options = array();
				$options['clientid'][] = 0; // site
				$app->logout( (int) $this->userid, $options);
			}
		}

		//Store the ban data in the database
		$result = $table->store();
		if (!$result) {
			$this->setError($table->getError());
		}

		// Set the id for the KunenaUserBan object in case we created a new ban.
		if ($result && $isnew) {
			$this->load($table->get('id'));
			self::storeInstance($this);
		}

		return $result;
	}
开发者ID:GoremanX,项目名称:Kunena-2.0,代码行数:86,代码来源:ban.php

示例6: save

 public function save()
 {
     if (!JRequest::checkToken()) {
         $this->app->enqueueMessage(JText::_('COM_KUNENA_ERROR_TOKEN'), 'error');
         $this->redirectBack();
     }
     $now = new JDate();
     $fields = array();
     $fields['title'] = JRequest::getString('title');
     $fields['description'] = JRequest::getVar('description', '', 'string', JREQUEST_ALLOWRAW);
     $fields['sdescription'] = JRequest::getVar('sdescription', '', 'string', JREQUEST_ALLOWRAW);
     $fields['created'] = JRequest::getString('created', $now->toMysql());
     $fields['published'] = JRequest::getInt('published', 1);
     $fields['showdate'] = JRequest::getInt('showdate', 1);
     $id = JRequest::getInt('id');
     $announcement = KunenaForumAnnouncementHelper::get($id);
     $announcement->bind($fields);
     if (!$announcement->authorise($id ? 'edit' : 'create') || !$announcement->save()) {
         $this->app->enqueueMessage($announcement->getError(), 'error');
         $this->redirectBack();
     }
     $this->app->enqueueMessage(JText::_($id ? 'COM_KUNENA_ANN_SUCCESS_EDIT' : 'COM_KUNENA_ANN_SUCCESS_ADD'));
     $this->setRedirect($announcement->getUrl('default', false));
 }
开发者ID:laiello,项目名称:senluonirvana,代码行数:24,代码来源:announcement.php

示例7: onBeforeStore

 protected function onBeforeStore($updateNulls)
 {
     // Do we have a "Created" set of fields?
     $created_on = $this->getColumnAlias('created_on');
     $created_by = $this->getColumnAlias('created_by');
     $modified_on = $this->getColumnAlias('modified_on');
     $modified_by = $this->getColumnAlias('modified_by');
     $locked_on = $this->getColumnAlias('locked_on');
     $locked_by = $this->getColumnAlias('locked_by');
     $title = $this->getColumnAlias('title');
     $slug = $this->getColumnAlias('slug');
     $hasCreatedOn = isset($this->{$created_on}) || property_exists($this, $created_on);
     $hasCreatedBy = isset($this->{$created_by}) || property_exists($this, $created_by);
     // first of all, let's unset fields that aren't related to the table (ie joined fields)
     $fields = $this->getTableFields();
     $properties = $this->getProperties();
     foreach ($properties as $property => $value) {
         // 'input' property is a reserved name
         if ($property == 'input') {
             continue;
         }
         if (!isset($fields[$property])) {
             unset($this->{$property});
         }
     }
     if ($hasCreatedOn && $hasCreatedBy) {
         $hasModifiedOn = isset($this->{$modified_on}) || property_exists($this, $modified_on);
         $hasModifiedBy = isset($this->{$modified_by}) || property_exists($this, $modified_by);
         if (empty($this->{$created_by}) || $this->{$created_on} == '0000-00-00 00:00:00' || empty($this->{$created_on})) {
             $uid = JFactory::getUser()->id;
             if ($uid) {
                 $this->{$created_by} = JFactory::getUser()->id;
             }
             JLoader::import('joomla.utilities.date');
             $date = new JDate();
             if (version_compare(JVERSION, '3.0', 'ge')) {
                 $this->{$created_on} = $date->toSql();
             } else {
                 $this->{$created_on} = $date->toMysql();
             }
         } elseif ($hasModifiedOn && $hasModifiedBy) {
             $uid = JFactory::getUser()->id;
             if ($uid) {
                 $this->{$modified_by} = JFactory::getUser()->id;
             }
             JLoader::import('joomla.utilities.date');
             $date = new JDate();
             if (version_compare(JVERSION, '3.0', 'ge')) {
                 $this->{$modified_on} = $date->toSql();
             } else {
                 $this->{$modified_on} = $date->toMysql();
             }
         }
     }
     // Do we have a set of title and slug fields?
     $hasTitle = isset($this->{$title}) || property_exists($this, $title);
     $hasSlug = isset($this->{$slug}) || property_exists($this, $slug);
     if ($hasTitle && $hasSlug) {
         if (empty($this->{$slug})) {
             // Create a slug from the title
             $this->{$slug} = FOFStringUtils::toSlug($this->{$title});
         } else {
             // Filter the slug for invalid characters
             $this->{$slug} = FOFStringUtils::toSlug($this->{$slug});
         }
         // Make sure we don't have a duplicate slug on this table
         $db = $this->getDbo();
         $query = $db->getQuery(true)->select($db->qn($slug))->from($this->_tbl)->where($db->qn($slug) . ' = ' . $db->q($this->{$slug}))->where('NOT ' . $db->qn($this->_tbl_key) . ' = ' . $db->q($this->{$this->_tbl_key}));
         $db->setQuery($query);
         $existingItems = $db->loadAssocList();
         $count = 0;
         $newSlug = $this->{$slug};
         while (!empty($existingItems)) {
             $count++;
             $newSlug = $this->{$slug} . '-' . $count;
             $query = $db->getQuery(true)->select($db->qn($slug))->from($this->_tbl)->where($db->qn($slug) . ' = ' . $db->q($newSlug))->where($db->qn($this->_tbl_key) . ' = ' . $db->q($this->{$this->_tbl_key}), 'AND NOT');
             $db->setQuery($query);
             $existingItems = $db->loadAssocList();
         }
         $this->{$slug} = $newSlug;
     }
     // Execute onBeforeStore<tablename> events in loaded plugins
     if ($this->_trigger_events) {
         $name = FOFInflector::pluralize($this->getKeyName());
         $dispatcher = JDispatcher::getInstance();
         $result = $dispatcher->trigger('onBeforeStore' . ucfirst($name), array(&$this, $updateNulls));
         if (in_array(false, $result, true)) {
             return false;
         } else {
             return true;
         }
     }
     return true;
 }
开发者ID:brojask,项目名称:colegio-abogados-joomla,代码行数:94,代码来源:table.php

示例8: getArticleData

	private function getArticleData($cat_id = '1', $levelpath = '1', $currentArticle = 1, $addPictures = true)
	{
		$logger = $this->getState('logger');
		
		$title = 'Overload Sample ';
		$alias = 'overload-sample-';
		$title .= $currentArticle.' in '.str_replace('.', '-', $levelpath);
		$alias .= $currentArticle.'-in-'.str_replace('.', '-', $levelpath);
		
		$url = str_replace('/administrator', '', JURI::base(true));
		$url = rtrim($url,'/');
		$picture1 = $addPictures ? '<img src="'.$url.'/images/sampledata/fruitshop/apple.jpg" align="left" />' : '';
		$picture2 = $addPictures ? '<img src="'.$url.'/images/sampledata/parks/animals/180px_koala_ag1.jpg" align="right" />' : '';
		
		$introtext = <<<ENDTEXT
$picture1<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec auctor velit blandit risus posuere sit amet sollicitudin enim dictum. Nunc a commodo magna. Cras mattis, purus et ornare dictum, velit mi dictum nisl, sed rutrum massa eros nec leo. Sed at nibh nec felis dignissim tristique. Mauris sed posuere velit. Curabitur vehicula dui libero. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean iaculis felis ac elit euismod vitae venenatis dui iaculis. Morbi nec ipsum sit amet erat scelerisque auctor ac eget elit. Phasellus ut mattis ipsum. In auctor lacinia porttitor. Aliquam erat volutpat. In hac habitasse platea dictumst. Pellentesque iaculis mi ut ante tempor pharetra.</p>
ENDTEXT;
		$fulltext = <<<ENDTEXT
<p>Aenean nisl velit, consectetur hendrerit ultricies eu, vehicula eu massa. Nunc elementum enim vitae tortor dignissim eget vulputate quam condimentum. Pellentesque ante felis, venenatis non malesuada a, sodales ut nunc. Morbi sed nulla <a href="http://www.joomla.org">sit amet erat cursus venenatis</a>. Nulla non diam id risus egestas varius vel nec nulla. Nullam pretium congue cursus. Nullam ultricies laoreet porttitor. Proin ultricies aliquam lacinia. Proin porta interdum enim eu ultrices. Maecenas id dui vitae nisl ultrices cursus quis et nisi. Sed rhoncus vestibulum eros vel faucibus. Nulla facilisi. Mauris lacus metus, aliquet eu iaculis vitae, tempor ac metus. Sed sem nunc, tempor vehicula condimentum at, ultricies a tellus. Proin dui velit, accumsan vitae facilisis mollis, tristique aliquet purus. Aliquam porta, orci nec feugiat semper, tortor nunc pulvinar lorem, sed ultricies mauris justo eu orci. Nullam urna leo, vehicula at interdum non, fringilla eget neque. Quisque dui metus, hendrerit ut porttitor non, dignissim eu ipsum.</p>
<p>Pellentesque ultricies adipiscing odio, <em>at interdum dui tempus ac</em>. Aliquam accumsan sem et tortor facilisis sagittis. Sed interdum erat in ante venenatis dignissim. Nulla neque metus, interdum a porta eu, lobortis quis libero. Maecenas condimentum lectus id nisi suscipit tempus. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas at neque diam. Suspendisse arcu purus, eleifend accumsan imperdiet in, porta ac ante. Nam lobortis tincidunt erat, non ornare mauris vestibulum non. Vivamus feugiat nunc pretium mi pharetra dictum. Donec auctor tincidunt pulvinar. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</p>
$picture2<p>Nunc feugiat porta faucibus. Nulla facilisi. Sed viverra laoreet mollis. Morbi ullamcorper lorem a lacus porttitor tristique. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean <strong>consequat</strong> tincidunt lacinia. Maecenas dictum volutpat lacus, nec malesuada ipsum congue sed. Sed nec neque erat. Donec eros urna, vulputate ac elementum sit amet, pharetra sit amet urna. Phasellus in lectus metus. Proin vitae diam augue, vel lacinia lectus. Ut tincidunt, dolor sit amet hendrerit gravida, augue mauris bibendum sapien, nec porta ipsum diam eget erat. In porta nisl eget odio placerat gravida commodo tortor feugiat. Donec in tincidunt dui. In in neque tellus. Phasellus velit lacus, viverra et sodales nec, porta in velit.</p>
<p>Etiam quis velit odio. Nunc dignissim enim vel enim blandit tempus. Integer pellentesque leo ac risus hendrerit sed consequat lacus elementum. Aenean placerat leo vitae nunc bibendum cursus. Ut ac dui diam. Vivamus massa tortor, consectetur at scelerisque eget, hendrerit et elit. Aliquam hendrerit quam posuere tellus sollicitudin sollicitudin. Ut eget lacinia metus. Curabitur vitae orci ac libero vestibulum commodo. Sed id nibh eu erat pretium tempus. Nullam suscipit fringilla tortor, ac pretium metus iaculis eu. Fusce pellentesque volutpat tortor, at interdum tortor blandit at. Morbi rhoncus euismod ultricies. Fusce sed massa at elit lobortis iaculis non id metus. Aliquam erat volutpat. Vivamus convallis mauris ut sapien tempus quis tempor nunc cursus. Quisque in lorem sem.</p>
ENDTEXT;
		jimport('joomla.utilities.date');
		$jNow = new JDate();

		if (version_compare(JVERSION, '3.0', 'ge')) {
			$now = $jNow->toSql();
		} else {
			$now = $jNow->toMysql();
		}

		$state  = (int) $this->getState('articlesstate', 1);

		$data = array(
			'id'			=> 0,
			'title'			=> $title,
			'alias'			=> $alias,
			'introtext'		=> $introtext,
			'fulltext'		=> $fulltext,
			'state'			=> $state,
			'sectionid'		=> 0,
			'mask'			=> 0,
			'catid'			=> $cat_id,
			'created'		=> $now,
			'created_by_alias' => 'Overload',
			'attribs'		=> array(
				"show_title"=>"","link_titles"=>"","show_intro"=>"","show_category"=>"","link_category"=>"","show_parent_category"=>"","link_parent_category"=>"","show_author"=>"","link_author"=>"","show_create_date"=>"","show_modify_date"=>"","show_publish_date"=>"","show_item_navigation"=>"","show_icons"=>"","show_print_icon"=>"","show_email_icon"=>"","show_vote"=>"","show_hits"=>"","show_noauth"=>"","alternative_readmore"=>"","article_layout"=>""
			),
			'version'		=> 1,
			'parentid'		=> 0,
			'ordering'		=> 0,
			'metakey'		=> '',
			'metadesc'		=> '',
			'access'		=> 1,
			'hits'			=> 0,
			'featured'		=> 0,
			'language'		=> '*',
			'associations'	=> array(),
			'metadata'		=> '{"tags":[]}',
			'state'			=> $state
		);
		
		return $data;
	}
开发者ID:nikosdion,项目名称:com_overload,代码行数:65,代码来源:process.php

示例9: checkout

 /**
  * Checks out a row
  *
  * @access public
  * @param	integer	The id of the user
  * @param 	mixed	The primary key value for the row
  * @return	boolean	True if successful, or if checkout is not supported
  */
 function checkout($who, $oid = null)
 {
     if (!in_array('checked_out', array_keys($this->getProperties()))) {
         return true;
     }
     $k = $this->_tbl_key;
     if ($oid !== null) {
         $this->{$k} = $oid;
     }
     jimport('joomla.utilities.date');
     $date = new JDate();
     $time = $date->toMysql();
     $query = 'UPDATE ' . $this->_db->nameQuote($this->_tbl) . ' SET checked_out = ' . (int) $who . ', checked_out_time = ' . $this->_db->Quote($time) . ' WHERE ' . $this->_tbl_key . ' = ' . $this->_db->Quote($this->{$k});
     $this->_db->setQuery($query);
     $this->checked_out = $who;
     $this->checked_out_time = $time;
     return $this->_db->query();
 }
开发者ID:Fellah,项目名称:govnobaki,代码行数:26,代码来源:table.php


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