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


PHP JDatabase::setQuery方法代码示例

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


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

示例1: getTypes

 /**
  * Method to get the content types.
  *
  * @return  array  An array of JContentType objects.
  *
  * @since   12.1
  * @throws  RuntimeException
  */
 public function getTypes()
 {
     $types = array();
     // Get the cache store id.
     $storeId = $this->getStoreId('getTypes');
     // Attempt to retrieve the types from cache first.
     $cached = $this->retrieve($storeId);
     // Check if the cached value is usable.
     if (is_array($cached)) {
         return $cached;
     }
     // Build the query to get the content types.
     $query = $this->db->getQuery(true);
     $query->select('a.*');
     $query->from($query->qn('#__content_types') . ' AS a');
     // Get the content types.
     $this->db->setQuery($query);
     $results = $this->db->loadObjectList();
     // Reorganize the type information.
     foreach ($results as $result) {
         // Create a new JContentType object.
         $type = $this->factory->getType();
         // Bind the type data.
         $type->bind($result);
         // Add the type, keyed by alias.
         $types[$result->alias] = $type;
     }
     // Store the types in cache.
     return $this->store($storeId, $types);
 }
开发者ID:prox91,项目名称:joomla-dev,代码行数:38,代码来源:helper.php

示例2: doExecute

 /**
  * Execute the application.
  *
  * @return  void
  */
 public function doExecute()
 {
     // Get the query builder class from the database and set it up
     // to select everything in the 'db' table.
     $query = $this->dbo->getQuery(true)->select('*')->from($this->dbo->qn('db'));
     // Push the query builder object into the database connector.
     $this->dbo->setQuery($query);
     // Get all the returned rows from the query as an array of objects.
     $rows = $this->dbo->loadObjectList();
     // Just dump the value returned.
     var_dump($rows);
 }
开发者ID:cuongnd,项目名称:etravelservice,代码行数:17,代码来源:ecr_comname.php

示例3: reorder

 /**
  * Compacts the ordering sequence of the selected records
  *
  * @access public
  * @param string Additional where query to limit ordering to a particular subset of records
  */
 function reorder($where = '')
 {
     $k = $this->_tbl_key;
     if (!in_array('ordering', array_keys($this->getProperties()))) {
         $this->setError(get_class($this) . ' does not support ordering');
         return false;
     }
     if ($this->_tbl == '#__content_frontpage') {
         $order2 = ", content_id DESC";
     } else {
         $order2 = "";
     }
     $query = 'SELECT ' . $this->_tbl_key . ', ordering' . ' FROM ' . $this->_tbl . ' WHERE ordering >= 0' . ($where ? ' AND ' . $where : '') . ' ORDER BY ordering' . $order2;
     $this->_db->setQuery($query);
     if (!($orders = $this->_db->loadObjectList())) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     // compact the ordering numbers
     for ($i = 0, $n = count($orders); $i < $n; $i++) {
         if ($orders[$i]->ordering >= 0) {
             if ($orders[$i]->ordering != $i + 1) {
                 $orders[$i]->ordering = $i + 1;
                 $query = 'UPDATE ' . $this->_tbl . ' SET ordering = ' . (int) $orders[$i]->ordering . ' WHERE ' . $k . ' = ' . $this->_db->Quote($orders[$i]->{$k});
                 $this->_db->setQuery($query);
                 $this->_db->query();
             }
         }
     }
     return true;
 }
开发者ID:Jonathonbyrd,项目名称:Joomla-Listings,代码行数:37,代码来源:table.php

示例4: getBrands

 public function getBrands()
 {
     $query = "SELECT a.group_id,u.*, ku.userName, ku.description, ku.image, ku.url FROM `#__user_usergroup_map` as a LEFT JOIN #__users as u ON u.id = a.user_id LEFT JOIN #__k2_users as ku ON ku.userID = a.user_id where a.group_id = 13;";
     $query_set = $this->dbo->setQuery($query);
     $items = $this->dbo->loadObjectList();
     return $items;
 }
开发者ID:rutvikd,项目名称:ak-recipes,代码行数:7,代码来源:migrate_k2_modules.php

示例5: doLoad

 /**
  * Method to load an object by primary id.
  *
  * @return  void
  *
  * @since   12.1
  * @throws  RuntimeException
  */
 protected function doLoad()
 {
     // Get the primary key.
     $primaryKey = $this->getTableKey('primary', 'primary');
     $primaryTable = $this->getTableExpression('primary');
     // Build the query object.
     $query = $this->db->getQuery(true);
     $query->select($this->getTableKeyExpression('primary', '*'));
     $query->from($primaryTable);
     $query->where($this->getTableKeyExpression('primary', 'primary') . ' = ' . (int) $this->{$primaryKey});
     // Get the subtables.
     $tables = $this->tables;
     unset($tables['primary']);
     // Add additional tables to the query.
     foreach ($tables as $alias => $table) {
         // Add the table select and join clauses.
         $query->select($this->getTableKeyExpression($alias, '*'));
         $query->join('INNER', $this->getTableExpression($alias));
     }
     // Get the content data.
     $this->db->setQuery($query);
     $data = $this->db->loadObject();
     // Check the type data.
     if (empty($data)) {
         throw new RuntimeException(JText::sprintf('JDATABASEOBJECT_NOT_FOUND', $this->{$primaryKey}, $primaryTable));
     }
     // Bind the data.
     $this->bind($data);
 }
开发者ID:prox91,项目名称:joomla-dev,代码行数:37,代码来源:object.php

示例6: getNewItemid

 public function getNewItemid($id)
 {
     $query = 'SELECT k2_item_id,new_item_id,item_type from #__k2_recipe_map where k2_item_id =  ' . $id . ';';
     $query_set = $this->dbo->setQuery($query);
     $newitem = $this->dbo->loadObject();
     return $newitem;
 }
开发者ID:rutvikd,项目名称:ak-recipes,代码行数:7,代码来源:find_hfrefs.php

示例7: getK2Users

 public function getK2Users()
 {
     $query = "SELECT id, userID, userName, description, image, url from #__k2_users ;";
     $query_set = $this->dbo->setQuery($query);
     $items = $this->dbo->loadObjectList();
     return $items;
 }
开发者ID:rutvikd,项目名称:ak-recipes,代码行数:7,代码来源:migrate_k2_users.php

示例8: testSetQuery

	/**
	 * Tests the JDatabase::setQuery method.
	 *
	 * @return  void
	 *
	 * @since   12.1
	 */
	public function testSetQuery()
	{
		$this->assertThat(
			$this->db->setQuery('SELECT * FROM #__dbtest'),
			$this->isInstanceOf('JDatabase'),
			'setQuery method should return an instance of JDatabase.'
		);
	}
开发者ID:robschley,项目名称:joomla-platform,代码行数:15,代码来源:JDatabaseTest.php

示例9: getK2Categories

 public function getK2Categories()
 {
     //$query = "SELECT * from #__k2_categories WHERE trash != 1 and published = 1 and extraFieldsGroup = 1 order by id;" ;
     $query = "SELECT * from #__k2_categories WHERE trash != 1 and published = 1 order by id;";
     $query_set = $this->dbo->setQuery($query);
     $categories = $this->dbo->loadObjectList();
     return $categories;
 }
开发者ID:rutvikd,项目名称:ak-recipes,代码行数:8,代码来源:extract_k2_ingredients.php

示例10: count

 /**
  * Count items.
  *
  * @return int
  */
 public function count()
 {
     $query = clone $this->query;
     $this->build($query);
     $query->select('COUNT(*)');
     $this->db->setQuery($query);
     $count = (int) $this->db->loadResult();
     KunenaError::checkDatabaseError();
     return $count;
 }
开发者ID:anawu2006,项目名称:PeerLearning,代码行数:15,代码来源:finder.php

示例11: getElementScripts

	public function getElementScripts(){
		$retArray = array();
		$this->db->setQuery("Select id, package, name, title, description, type From #__facileforms_scripts Where published = 1 And type = 'Element Validation'");
		$retArray['validation'] = $this->db->loadObjectList();
		$this->db->setQuery("Select id, package, name, title, description, type From #__facileforms_scripts Where published = 1 And type = 'Element Action'");
		$retArray['action'] = $this->db->loadObjectList();
		$this->db->setQuery("Select id, package, name, title, description, type From #__facileforms_scripts Where published = 1 And type = 'Element Init'");
		$retArray['init'] = $this->db->loadObjectList();;
		return $retArray;
	}
开发者ID:rkern21,项目名称:videoeditor,代码行数:10,代码来源:easymode.class.php

示例12: jotcache_upgrade

function jotcache_upgrade(JDatabase $db)
{
    $message = '';
    $query = $db->getQuery(true);
    $query->select('COUNT(*)')->from('#__jotcache_exclude')->where('type=1');
    $tplex_count = $db->setQuery($query)->loadResult();
    if ($tplex_count == 0) {
        return false;
    }
    $query->clear('where');
    $query->where('type=4');
    $count = $db->setQuery($query)->loadResult();
    if ($count == 0) {
        $query->clear('select')->clear('where');
        $query->select($db->quoteName('value'))->from($db->quoteName('#__template_styles', 's'))->where('name=s.id')->where('type=1')->order('s.home');
        $defs = $db->setQuery($query)->loadResultArray();
        $positions = array();
        foreach ($defs as $def) {
            $def_array = unserialize($def);
            $positions = array_merge($positions, $def_array);
        }
        $query->clear();
        $query->select('position')->from('#__modules')->where('client_id = 0')->where('published = 1')->where('position <>' . $db->quote(''))->group('position')->order('position');
        $db->setQuery($query);
        $items = $db->loadResultArray();
        $cleaned_positions = array();
        foreach ($items as $item) {
            if (array_key_exists($item, $positions)) {
                $cleaned_positions[$item] = $positions[$item];
            }
        }
        $defs = serialize($cleaned_positions);
        $query->clear();
        $query->insert('#__jotcache_exclude')->columns('name,value,type')->values('1,' . $db->quote($defs) . ',4');
        if ($db->setQuery($query)->query()) {
            $message = "TABLE #__jotcache_exclude has been upgraded. Check JotCache TPL exclude definitions for correct values.";
        } else {
            JError::raiseNotice(100, $db->getErrorMsg());
        }
        return $message;
    }
}
开发者ID:alesconti,项目名称:FF_2015,代码行数:42,代码来源:install.php

示例13: loadK2ItemsMap

 public function loadK2ItemsMap()
 {
     $db = $this->dbo;
     $query = "select * from #__k2_recipe_map  ;";
     $query_set = $this->dbo->setQuery($query);
     $items = $this->dbo->loadObjectList();
     $this->k2_items_maps = array();
     foreach ($items as $key => $item) {
         $obj = new stdClass();
         $obj->item_type = $item->item_type;
         $obj->new_item_id = $item->new_item_id;
         $this->k2_items_maps[$item->k2_item_id] = $obj;
     }
 }
开发者ID:rutvikd,项目名称:ak-recipes,代码行数:14,代码来源:migrate_k2_menus.php

示例14: canDelete

 /**
  * Generic check for whether dependencies exist for this object in the database schema
  *
  * Can be overloaded/supplemented by the child class
  *
  * @param   mixed  $pk     An optional primary key value check the row for.  If not
  * set the instance property value is used.
  * @param   array  $joins  An optional array to compiles standard joins formatted like:
  * [label => 'Label', name => 'table name' , idfield => 'field', joinfield => 'field']
  *
  * @return  boolean  True on success.
  *
  * @deprecated    12.1
  * @link    http://docs.joomla.org/JTable/canDelete
  * @since   11.1
  */
 public function canDelete($pk = null, $joins = null)
 {
     // Deprecation warning.
     JLog::add('JTable::canDelete() is deprecated.', JLog::WARNING, 'deprecated');
     // Initialise variables.
     $k = $this->_tbl_key;
     $pk = is_null($pk) ? $this->{$k} : $pk;
     // If no primary key is given, return false.
     if ($pk === null) {
         return false;
     }
     if (is_array($joins)) {
         // Get a query object.
         $query = $this->_db->getQuery(true);
         // Setup the basic query.
         $query->select($this->_db->quoteName($this->_tbl_key));
         $query->from($this->_db->quoteName($this->_tbl));
         $query->where($this->_db->quoteName($this->_tbl_key) . ' = ' . $this->_db->quote($this->{$k}));
         $query->group($this->_db->quoteName($this->_tbl_key));
         // For each join add the select and join clauses to the query object.
         foreach ($joins as $table) {
             $query->select('COUNT(DISTINCT ' . $table['idfield'] . ') AS ' . $table['idfield']);
             $query->join('LEFT', $table['name'] . ' ON ' . $table['joinfield'] . ' = ' . $k);
         }
         // Get the row object from the query.
         $this->_db->setQuery((string) $query, 0, 1);
         $row = $this->_db->loadObject();
         // Check for a database error.
         if ($this->_db->getErrorNum()) {
             $this->setError($this->_db->getErrorMsg());
             return false;
         }
         $msg = array();
         $i = 0;
         foreach ($joins as $table) {
             $k = $table['idfield'] . $i;
             if ($row->{$k}) {
                 $msg[] = JText::_($table['label']);
             }
             $i++;
         }
         if (count($msg)) {
             $this->setError("noDeleteRecord" . ": " . implode(', ', $msg));
             return false;
         } else {
             return true;
         }
     }
     return true;
 }
开发者ID:NavaINT1876,项目名称:ccustoms,代码行数:66,代码来源:table.php

示例15: query

 /**
  * Returns an associative array of records from a query.
  * 
  * @param $query
  */
 function query($query)
 {
     switch (strtolower(substr(trim($query), 0, 6))) {
         case 'select':
             $this->_db->setQuery($query);
             $results = $this->_db->loadAssocList();
             return $results;
             break;
         case 'insert':
         case 'update':
             $this->_db->setQuery($query);
             $result = $this->_db->query();
             return $result;
             break;
     }
     return false;
 }
开发者ID:Jonathonbyrd,项目名称:Joomla-Listings,代码行数:22,代码来源:sugar_table.php


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