本文整理汇总了PHP中JDatabaseQuery类的典型用法代码示例。如果您正苦于以下问题:PHP JDatabaseQuery类的具体用法?PHP JDatabaseQuery怎么用?PHP JDatabaseQuery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JDatabaseQuery类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: getList
/**
* Get a list of logged users.
*
* @param JObject The module parameters.
* @return mixed An array of articles, or false on error.
*/
public static function getList($params)
{
// Initialise variables
$db = JFactory::getDbo();
$user = JFactory::getUser();
$query = new JDatabaseQuery();
$query->select('s.time, s.client_id, u.id, u.name, u.username');
$query->from('#__session AS s');
$query->leftJoin('#__users AS u ON s.userid = u.id');
$query->where('s.guest = 0');
$db->setQuery($query, 0, $params->get('count', 5));
$results = $db->loadObjectList();
// Check for database errors
if ($error = $db->getErrorMsg()) {
JError::raiseError(500, $error);
return false;
}
foreach ($results as $k => $result) {
$results[$k]->logoutLink = '';
if ($user->authorise('core.manage', 'com_users')) {
$results[$k]->editLink = JRoute::_('index.php?option=com_users&task=user.edit&id=' . $result->id);
$results[$k]->logoutLink = JRoute::_('index.php?option=com_login&task=logout&uid=' . $result->id . '&' . JUtility::getToken() . '=1');
}
if ($params->get('name', 1) == 0) {
$results[$k]->name = $results[$k]->username;
}
}
return $results;
}
开发者ID:akksi,项目名称:jcg,代码行数:35,代码来源:helper.php
示例17: onAfterBuildQuery
/**
* Modify the query to filter list objects by n:n relation.
*
* @param F0FModel $model The model on which operate.
* @param JDatabaseQuery $query The query to alter.
*/
public function onAfterBuildQuery(&$model, &$query)
{
$input = new F0FInput();
$db = $model->getDbo();
// Retrieve the relations configuration for this table
$table = $model->getTable();
$key = $table->getConfigProviderKey() . '.relations';
$relations = $table->getConfigProvider()->get($key, array());
// For each multiple type relation add the filter query
foreach ($relations as $relation) {
if ($relation['type'] == 'multiple') {
// Get complete relation fields
$relation = array_merge(array('itemName' => $relation['itemName']), $table->getRelations()->getRelation($relation['itemName'], $relation['type']));
// Model only save $table->getKnownFields as state, so we look into the input
$filter_name = $relation['itemName'];
$model_filter_value = $input->getInt($filter_name);
// Build the conditions based on relation configuration
if (!empty($model_filter_value)) {
$query->innerJoin(sprintf('%1$s ON %1$s.%2$s = %3$s.%4$s', $db->qn($relation['pivotTable']), $db->qn($relation['ourPivotKey']), $db->qn($table->getTableName()), $db->qn($relation['localKey'])));
$query->where(sprintf('%s.%s = %s', $db->qn($relation['pivotTable']), $db->qn($relation['theirPivotKey']), $model_filter_value));
}
}
}
}
开发者ID:fede91it,项目名称:fof-nnrelation,代码行数:30,代码来源:nnrelation.php
示例18: testFormat
/**
* Tests the JDatabaseQuery::format method.
*
* @return void
*
* @covers JDatabaseQuery::format
* @since 12.3
*/
public function testFormat()
{
$result = $this->_instance->format('SELECT %n FROM %n WHERE %n = %a', 'foo', '#__bar', 'id', 10);
$expected = 'SELECT ' . $this->_instance->qn('foo') . ' FROM ' . $this->_instance->qn('#__bar') .
' WHERE ' . $this->_instance->qn('id') . ' = 10';
$this->assertThat(
$result,
$this->equalTo($expected),
'Line: ' . __LINE__ . '.'
);
$result = $this->_instance->format('SELECT %n FROM %n WHERE %n = %t OR %3$n = %Z', 'id', '#__foo', 'date');
$expected = 'SELECT ' . $this->_instance->qn('id') . ' FROM ' . $this->_instance->qn('#__foo') .
' WHERE ' . $this->_instance->qn('date') . ' = ' . $this->_instance->currentTimestamp() .
' OR ' . $this->_instance->qn('date') . ' = ' . $this->_instance->nullDate(true);
$this->assertThat(
$result,
$this->equalTo($expected),
'Line: ' . __LINE__ . '.'
);
}
开发者ID:realityking,项目名称:joomla-platform,代码行数:30,代码来源:JDatabaseQueryTest.php
示例19: prepareFilterFundingState
/**
* Prepare filter by funding state.
*
* @param JDatabaseQuery $query
*/
protected function prepareFilterFundingState(&$query)
{
$db = JFactory::getDbo();
// Filter by funding state.
$filter = (int) $this->getState($this->context . '.filter_funding_state');
switch ($filter) {
case 1:
// Successfully funded.
jimport('joomla.date.date');
$date = new JDate();
$today = $date->toSql();
$query->where('a.funding_end < ' . $db->quote($today) . ' AND a.funded >= a.goal');
break;
}
}
开发者ID:ITPrism,项目名称:CrowdfundingDistribution,代码行数:20,代码来源:category.php
示例20: getListQuery
/**
* Method to get the database query
*
* @return JDatabaseQuery The database query
* @since 1.6
*/
protected function getListQuery()
{
$enabled = $this->getState('filter.enabled');
$type = $this->getState('filter.type');
$client = $this->getState('filter.client_id');
$group = $this->getState('filter.group');
$hideprotected = $this->getState('filter.hideprotected');
$query = new JDatabaseQuery();
$query->select('*');
$query->from('#__extensions');
$query->where('state=0');
if ($hideprotected) {
$query->where('protected!=1');
}
if ($enabled != '') {
$query->where('enabled=' . intval($enabled));
}
if ($type) {
$query->where('type=' . $this->_db->Quote($type));
}
if ($client != '') {
$query->where('client_id=' . intval($client));
}
if ($group != '' && in_array($type, array('plugin', 'library', ''))) {
$query->where('folder=' . $this->_db->Quote($group == '*' ? '' : $group));
}
// Filter by search in id
$search = $this->getState('filter.search');
if (!empty($search) && stripos($search, 'id:') === 0) {
$query->where('extension_id = ' . (int) substr($search, 3));
}
return $query;
}
开发者ID:scarsroga,项目名称:blog-soa,代码行数:39,代码来源:manage.php
注:本文中的JDatabaseQuery类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论