當前位置: 首頁>>代碼示例>>PHP>>正文


PHP JDatabaseQuery類代碼示例

本文整理匯總了PHP中JDatabaseQuery的典型用法代碼示例。如果您正苦於以下問題:PHP JDatabaseQuery類的具體用法?PHP JDatabaseQuery怎麽用?PHP JDatabaseQuery使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了JDatabaseQuery類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: modifyQuery

 protected function modifyQuery(JDatabaseQuery &$query)
 {
     $query->where("NOT deleted");
     if (isset($this->leader)) {
         if ($this->leader instanceof Leader) {
             $query->where("leaderid = " . $this->leader->id);
         } else {
             if (is_int($this->leader)) {
                 $query->where("leaderid = " . $this->leader);
             } else {
                 if (ctype_digit($this->leader)) {
                     $query->where("leaderid = " . (int) $this->leader);
                 }
             }
         }
     }
     if (isset($this->walkProgramme)) {
         if ($this->walkProgramme instanceof WalkProgramme) {
             $wpID = $this->walkProgramme->id;
         } else {
             $wpID = (int) $this->walkProgramme;
         }
         $query->join('INNER', 'walkprogrammewalklinks ON WalkProgrammeWalkID = walkprogrammewalks.SequenceID');
         $query->where("walkprogrammewalklinks.ProgrammeID = " . $wpID);
     }
     if (isset($this->startTimeMax)) {
         $query->where("meettime <= '" . strftime("%H:%M", $this->startTimeMax) . "'");
     }
 }
開發者ID:SheffieldWalkingGroup,項目名稱:swgwebsite,代碼行數:29,代碼來源:WalkInstanceFactory.php

示例2: prepareOrder

 /**
  * Prepare result ordering.
  *
  * @param \JDatabaseQuery $query
  * @param array $options
  */
 protected function prepareOrder(&$query, $options)
 {
     // Filter by state.
     if (array_key_exists('order', $options)) {
         // Prepare direction of ordering.
         $direction = !array_key_exists('order_dir', $options) ? 'DESC' : $options['order_dir'];
         if (!in_array($direction, $this->allowedDirections, true)) {
             $direction = 'DESC';
         }
         switch ($options['order']) {
             case Constants::ORDER_BY_LOCATION_NAME:
                 // Order by location name.
                 $query->order('l.name ' . $direction);
                 break;
             case Constants::ORDER_BY_NUMBER_OF_PROJECTS:
                 // Order by location name.
                 $query->order('project_number ' . $direction);
                 break;
             default:
                 // Order by project title.
                 $query->order('a.title ' . $direction);
                 break;
         }
     }
 }
開發者ID:bellodox,項目名稱:CrowdFunding,代碼行數:31,代碼來源:Base.php

示例3: toDatabase

 /**
  * Adds fields on this event to a query being prepared to go into the database
  * @param JDatabaseQuery &$query Query being prepared. Modified in place.
  */
 public function toDatabase(JDatabaseQuery &$query)
 {
     foreach ($this->dbmappings as $var => $dbField) {
         if (isset($this->{$var})) {
             $query->set($dbField . " = '" . $query->escape($this->{$var}) . "'");
         }
     }
 }
開發者ID:SheffieldWalkingGroup,項目名稱:swgwebsite,代碼行數:12,代碼來源:SWGBaseModel.php

示例4: modifyQuery

 protected function modifyQuery(JDatabaseQuery &$query)
 {
     $showWhat = array();
     if ($this->getNormal) {
         $showWhat[] = "shownormal";
     }
     if ($this->getNewMember) {
         $showWhat[] = "shownewmember";
     }
     $query->where("(" . implode(" OR ", $showWhat) . ")");
 }
開發者ID:SheffieldWalkingGroup,項目名稱:swgwebsite,代碼行數:11,代碼來源:SocialFactory.php

示例5: addFilter

 /**
  * add filter to query
  *
  * @param   JDatabaseQuery  $query  query object
  *
  * @return JDatabaseQuery
  */
 public function addFilter(JDatabaseQuery $query)
 {
     if (!$this->filterField) {
         return $query;
     }
     $db = JFactory::getDbo();
     //since joomla 3.0 filter_value can be '' too not only filterNullValue
     if (isset($this->filter_value) && strlen($this->filter_value) > 0 && $this->filter_value != $this->filterNullValue) {
         $query->where(" c." . $this->filterField . " = " . $db->escape($this->filter_value, true));
     }
     return $query;
 }
開發者ID:jaanusnurmoja,項目名稱:redjoomla,代碼行數:19,代碼來源:translationRwf_formFilter.php

示例6: addFilter

 /**
  * add filter to query
  *
  * @param   JDatabaseQuery  $query  query object
  *
  * @return JDatabaseQuery
  */
 public function addFilter(JDatabaseQuery $query)
 {
     if (!$this->filterField) {
         return $query;
     }
     $db = JFactory::getDbo();
     //since joomla 3.0 filter_value can be '' too not only filterNullValue
     if (isset($this->filter_value) && strlen($this->filter_value) > 0 && $this->filter_value != $this->filterNullValue) {
         $query->join('INNER', '#__rwf_fields AS rwff ON rwff.id = c.field_id');
         $query->where("rwff.form_id = " . $db->escape($this->filter_value, true));
     }
     return $query;
 }
開發者ID:jaanusnurmoja,項目名稱:redjoomla,代碼行數:20,代碼來源:translationRwf_valueformFilter.php

示例7: sqlValues

 /**
  * Converts an array of values to a string that can be used in SQL to set
  * the according values in a query.
  *
  * @param   array           $data  Values that should be processed.
  * @param   JDatabaseQuery  $q     Optional query object for escaping.
  *
  * @return array
  */
 public static function sqlValues($data, $q = null)
 {
     $output = array();
     foreach ($data as $key => $value) {
         if ($value !== null) {
             if ($q) {
                 $value = $q->escape($value);
             }
             $output[] = $key . ' = "' . $value . '"';
         }
     }
     return $output;
 }
開發者ID:Harmageddon,項目名稱:com_monitor,代碼行數:22,代碼來源:helper.php

示例8: modifyQuery

 protected function modifyQuery(JDatabaseQuery &$query)
 {
     $showWhat = array();
     if ($this->getWithWalks) {
         $showWhat[] = "showWithWalks";
     }
     if ($this->getWithSocials) {
         $showWhat[] = "showWithSocials";
     }
     if ($this->getWithWeekends) {
         $showWhat[] = "showWithWeekends";
     }
     $query->where("(" . implode(" OR ", $showWhat) . ")");
 }
開發者ID:SheffieldWalkingGroup,項目名稱:swgwebsite,代碼行數:14,代碼來源:DummyEventFactory.php

示例9: prepareOrder

 /**
  * Prepare result ordering.
  *
  * @param \JDatabaseQuery $query
  * @param array $options
  */
 protected function prepareOrder(&$query, $options)
 {
     // Filter by state.
     if (isset($options["order"])) {
         // Prepare direction of ordering.
         $direction = !isset($options["order_dir"]) ? "DESC" : $options["order_dir"];
         if (!in_array($direction, $this->allowedDirections)) {
             $direction = "DESC";
         }
         switch ($options["order"]) {
             case Constants::ORDER_BY_LOCATION_NAME:
                 // Order by location name.
                 $query->order("l.name " . $direction);
                 break;
             case Constants::ORDER_BY_NUMBER_OF_PROJECTS:
                 // Order by location name.
                 $query->order("project_number " . $direction);
                 break;
             default:
                 // Order by project title.
                 $query->order("a.title " . $direction);
                 break;
         }
     }
 }
開發者ID:Eautentik,項目名稱:CrowdFunding,代碼行數:31,代碼來源:Base.php

示例10: countItems

 /**
  * Adds Count Items for Category Manager.
  *
  * @param   JDatabaseQuery  $query  The query object of com_categories
  *
  * @return  JDatabaseQuery
  *
  * @since   3.4
  */
 public static function countItems($query)
 {
     // Join articles to categories and count published items
     $query->select('COUNT(DISTINCT cp.id) AS count_published');
     $query->join('LEFT', '#__newsfeeds AS cp ON cp.catid = a.id AND cp.published = 1');
     // Count unpublished items
     $query->select('COUNT(DISTINCT cu.id) AS count_unpublished');
     $query->join('LEFT', '#__newsfeeds AS cu ON cu.catid = a.id AND cu.published = 0');
     // Count archived items
     $query->select('COUNT(DISTINCT ca.id) AS count_archived');
     $query->join('LEFT', '#__newsfeeds AS ca ON ca.catid = a.id AND ca.published = 2');
     // Count trashed items
     $query->select('COUNT(DISTINCT ct.id) AS count_trashed');
     $query->join('LEFT', '#__newsfeeds AS ct ON ct.catid = a.id AND ct.published = -2');
     return $query;
 }
開發者ID:SysBind,項目名稱:joomla-cms,代碼行數:25,代碼來源:newsfeeds.php

示例11: testUnionAllTwo

 /**
  * Tests the JDatabaseQuery::unionAll method.
  *
  * @return  void
  *
  * @since   13.1
  */
 public function testUnionAllTwo()
 {
     TestReflection::setValue($this->_instance, 'unionAll', null);
     $this->_instance->unionAll('SELECT name FROM foo');
     $this->_instance->unionAll('SELECT name FROM bar');
     $teststring = (string) TestReflection::getValue($this->_instance, 'unionAll');
     $this->assertThat($teststring, $this->equalTo(PHP_EOL . "UNION ALL (SELECT name FROM foo)" . PHP_EOL . "UNION ALL (SELECT name FROM bar)"), 'Tests rendered query with two union alls sequentially.');
 }
開發者ID:akirsoft,項目名稱:joomla-cms,代碼行數:15,代碼來源:JDatabaseQueryTest.php

示例12: getOptions

 /**
  * Method to get a list of options for a list input.
  *
  * @return      array           An array of JHtml options.
  */
 protected function getOptions()
 {
     $db = JFactory::getDBO();
     $query = new JDatabaseQuery();
     $query->select('#__helloworld.id as id,greeting,#__categories.title as category,catid');
     $query->from('#__helloworld');
     $query->leftJoin('#__categories on catid=#__categories.id');
     $db->setQuery((string) $query);
     $messages = $db->loadObjectList();
     $options = array();
     if ($messages) {
         foreach ($messages as $message) {
             $options[] = JHtml::_('select.option', $message->id, $message->greeting . ($message->catid ? ' (' . $message->category . ')' : ''));
         }
     }
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
開發者ID:TFToto,項目名稱:playjoom-builds,代碼行數:23,代碼來源:playjoom.php

示例13: getOptions

 /**
  * Method to get a list of options for a list input.
  *
  * @return      array           An array of JHtml options.
  */
 protected function getOptions()
 {
     $db = JFactory::getDBO();
     $query = new JDatabaseQuery();
     $query->select('#__jpaudiotracks.id as id,
                                                    pathatweb,
                                                    pathatlocal,
                                                    file,
                                                    title,
                                                    alias,
                                                    tracknumber,
                                                    mediatype,
                                                    bit_rate,
                                                    sample_rate,
                                                    channels,
                                                    channelmode,
                                                    filesize,
                                                    length,
                                                    catid,
                                                    add_datetime,
                                                    artist,
                                                    album,
                                                    year,
                                                    description,
                                                    lyrics,
                                                    frontcover,
                                                    backcover,
                                                    encoder,
                                                    metakey,
                                                    metadesc,
                             #__categories.title as category,catid');
     $query->from('#__jpaudiotracks');
     $query->leftJoin('#__categories on catid=#__categories.id');
     $db->setQuery((string) $query);
     $tracks = $db->loadObjectList();
     $options = array();
     if ($tracks) {
         foreach ($tracks as $track) {
             $options[] = JHtml::_('select.option', $track->id, $track->name . ($track->catid ? ' (' . $track->category . ')' : ''));
         }
     }
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
開發者ID:TFToto,項目名稱:playjoom-builds,代碼行數:49,代碼來源:audiotrack.php

示例14: implode

	static function &getModules()
	{
		static $modules;
		
		if (!is_null($modules))
			return $modules;

		$mainframe = JFactory::getApplication();

		$user =& JFactory::getUser();
		$db	=& JFactory::getDBO();
		$aid = $user->get('aid', 0);

		$groups	= implode(',', $user->getAuthorisedViewLevels());
		$query = new JDatabaseQuery;
		$query->select('id, title, module, position, content, showtitle, params, mm.menuid');
		$query->from('#__modules AS m');
		$query->join('LEFT','#__modules_menu AS mm ON mm.moduleid = m.id');
		$query->where('m.published = 1');

		if (!$user->authorise('core.admin',1)) {
			$query->where('m.access IN (' . $groups . ')');
		}

		$query->where('m.client_id = ' . (int)$mainframe->getClientId());
		$query->order('position, ordering'); 

		$db->setQuery($query);
		$modules = $db->loadObjectList('id');

		if ($db->getErrorNum()) 
		{
			$modules = array();
		}

		foreach ($modules as $key => $mod)
		{
			$module =& $modules[$key];
			$file = $module->module;
			$custom = substr($file, 0, 4) == 'mod_' ? 0 : 1;
			$module->user = $custom;
			$module->name = $custom ? $module->title : substr( $file, 4 );
			$module->style	= null;
			$module->position = strtolower($module->position);
		}
			
		return $modules;
	}
開發者ID:rkern21,項目名稱:videoeditor,代碼行數:48,代碼來源:class.ModuleHelper.php

示例15: getOptions

 /**
  * Method to get a list of options for a list input.
  *
  * @return      array           An array of JHtml options.
  */
 protected function getOptions()
 {
     $db = JFactory::getDBO();
     $query = new JDatabaseQuery();
     $query->select('#__quipforum_boards.id as id,topic');
     $query->from('#__quipforum_boards');
     $db->setQuery((string) $query);
     $messages = $db->loadObjectList();
     $options = array();
     if ($messages) {
         //if($this->allow_all)
         //	$options[] = JHtml::_('select.option', 0, 'Any');
         foreach ($messages as $message) {
             $options[] = JHtml::_('select.option', $message->id, $message->topic);
         }
     }
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
開發者ID:rgeraldporter,項目名稱:com_quipforum,代碼行數:24,代碼來源:board.php


注:本文中的JDatabaseQuery類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。