<?php
/**
* @package Pygalle
* @copyright Copyright (C) 2009 Erik Finnegan. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* @author hide@address.com
* Joomla! and Pygalle EVE Corporate Intranet are free software.
* This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');
pyimport( 'tables.table');
class PyTableRefining extends PyTable {
/**
* @access protected
*/
function __construct( &$db ) {
parent::__construct( '#__py_refining', 'id', $db);
}
function getRefiningLogs($limit = 100, $ids = null) {
$querylimit = "";
$exactid = "";
if ( $ids === null) {
if ($limit !== null) {
/* this is calculating the last n rows. Not needed for now.
$query = 'SELECT count(*) FROM #__py_refining WHERE `published` = 1';
$db->setQuery($query);
$numrows = $db->loadResult();
$this->_log->trace($db);
$limit = $numrows - $limit;
*/
$querylimit = " LIMIT $limit";
}
} else {
if ( !is_array($ids)) { $ids = array( $ids); }
$exactid = ' AND (';
$_first = true;
foreach ($ids as $oneId) {
if ( $_first) {
$_first = false;
} else {
$exactid .= ' OR ';
}
$exactid .= "y.`id` = $oneId";
}
$exactid .= ') ';
}
$query = 'SELECT y.*, u.`name` AS `createdByName`, o.`name` AS `mineral`'
. ' FROM #__py_refining AS y'
. ' LEFT OUTER JOIN #__users AS u ON y.`modifiedBy` = u.`id`'
. ' LEFT OUTER JOIN #__py_minerals AS o ON y.`typeId` = o.`eveTypeId`'
. ' WHERE y.`published` = 1'
. $exactid
. ' GROUP BY y.`id`'
. ' ORDER BY y.`date` DESC '
. $querylimit;
return $this->loadObjectList( $query);
}
}
?>