/** * Build an SQL query to load the list data. * * * @return JDatabaseQuery * @since 1.6 */ protected function getListQuery() { // Create a new query object. $worlddb = JTrinityCoreUtilities::getWorldDBName(JRequest::getVar('realmid')); $db = JTrinityCoreDBHelper::getDB(); $query = $db->getQuery(true); // Select the required fields from the table. $query->select($this->getState('list.select', 'DISTINCT a.entry as itemid, itemlevel, requiredlevel, a.name as englishname, quality, allowablerace, subclass, class, inventorytype')); $query->from($worlddb . '.item_template AS a'); $query->where('a.flags<>16 AND (a.name IS NOT NULL) AND (a.name not like \'%deprecated%\') AND (a.name not like \'%test%\')'); $name = "a.name"; $locale = JTrinityCoreUtilities::getLocale(); if ($locale > 1) { $name = "name_loc" . $locale; $query->select($name . " as name"); $query->where($name . " IS NOT NULL"); $query->join('INNER', $worlddb . '.locales_item AS li ON li.entry=a.entry '); #__users AS uc ON uc.id=a.checked_out } else { $query->select("a.name as name"); } // Filter by class state $class = $this->getState('filter.class_id'); if (is_numeric($class)) { $query->where('a.class = ' . (int) $class); } // Filter on quality. $quality = $this->getState('filter.quality_id'); if (is_numeric($quality)) { $query->where('a.Quality =' . $quality); } // Filter on Inventory Type. $inventory = $this->getState('filter.inventory_id'); if (is_numeric($inventory)) { $query->where('a.InventoryType =' . $inventory); } // Filter on allowable class $allowableclass = $this->getState('filter.allowableclass'); if (is_numeric($allowableclass)) { $query->where('a.AllowableClass =' . $allowableclass); } // Filter by search in title. $search = $this->getState('filter.search'); if (!empty($search)) { if (stripos($search, 'itemid:') === 0) { $query->where('a.displayid = ' . (int) substr($search, 7)); } else { if (stripos($search, 'itemlevel:') === 0) { $query->where('itemlevel = ' . (int) substr($search, 10)); } } if (stripos($search, 'requiredlevel:') === 0) { $query->where('requiredlevel = ' . (int) substr($search, 14)); } else { $search = $db->Quote('%' . $db->escape($search, true) . '%'); $query->where('(' . $name . ' LIKE ' . $search . ')'); } } // Add the list ordering clause. $orderCol = $this->state->get('list.ordering', 'i.name'); $orderDirn = $this->state->get('list.direction', 'asc'); //echo "Order field=".$orderCol."---<br>"; if ($orderCol == 'a.name' || $orderCol == 'name') { $orderCol = 'name '; } if ($orderCol == 'a.itemid' || $orderCol == 'itemid') { $orderCol = 'itemid '; } if ($orderCol == 'a.itemlevel' || $orderCol == 'itemlevel') { $orderCol = 'itemlevel '; } //sqlsrv change /*if($orderCol == 'access_level') $orderCol = 'ag.title';*/ $query->order($db->escape($orderCol . ' ' . $orderDirn)); // echo nl2br(str_replace('#__','jos_',$query)); //JLog::add('Query='.$query, JLog::WARNING, 'deprecated'); //JError::raiseError(0, JText::sprintf('DB Name antes='.$db->getDatabase()." Version=".$db->getVersion()." connected=".$db->connected(), 'hola')); return $query; }
protected function getMaxDurability($itemid, $realmid) { $worlddbname = JTrinityCoreUtilities::getWorldDBName($realmid); $dbo = JTrinityCoreDBHelper::getDB(); $sql = "SELECT maxDurability FROM " . $worlddbname . ".item_template WHERE entry=" . $itemid; $dbo->setQuery($sql); $max = $dbo->loadResult(); if (!$max) { $max = 0; } return $max; }