All pastes #420247 Raw Edit

plat

public php v1 · immutable
·published 2007-04-02 00:06 UTC
rendered paste body
<?phpclass MemberStats {var $name;var $mysqli;var $member_id;var $raid_count = 0;var $loot_count;    function __construct($id, $mysqli) {        $this->member_id = $id;        $this->mysqli = $mysqli;        $this->populateStats();            }        function populateStats()    {        //get member name        $statement = "SELECT name from icono.raid_members where id = ?";        $statement = $this->mysqli->prepare($statement);        $statement->bind_param("i", $this->member_id);        $statement->execute() or die(mysqli_error());        $statement->bind_result($this->name);        $statement->fetch();        $statement->close();            //get total raids            $statement = "SELECT Count(*) as raid_count                FROM icono.raid_attendance                WHERE member_id = ? AND active ='1'                GROUP BY member_id";        $statement = $this->mysqli->prepare($statement);        $statement->bind_param("i", $this->member_id);        $statement->execute() or die (mysqli_error());        $statement->bind_result($this->raid_count);        $statement->fetch();        $statement->close();           //get loot count        $statement = "SELECT name, tier_id, COUNT(*) as cnt FROM icono.raid_loot LEFT JOIN icono.loot_class on class_id = icono.loot_class.id where member_id = ?        group by class_id, tier_id";        $statement = $this->mysqli->prepare($statement);        $statement->bind_param("i", $this->member_id);        $statement->execute() or die (mysqli_error());        $statement->bind_result($class, $tier, $count);                while($statement->fetch())        {                $this->loot_count["$class"]["$tier"] = $count;        }                  $statement->close();    }    function memberExists()    {          if(!empty($this->name))                return true;        return false;    }    function getRaidCount(){               return $this->raid_count;    }            function getLootCount($class, $tier)    {            if(strtolower($tier) == "total")        {            $total = 0;            if(isset($this->loot_count[$class]))                foreach($this->loot_count[$class] as $v)                    $total += $v;                                return $total;                    }                return isset($this->loot_count[$class][$tier]) ? $this->loot_count[$class][$tier] : 0;            }           function getRatio($class){        if($this->getLootCount($class, "total") == 0)                return $this->getRaidCount();                        return round($this->getRaidCount() / $this->getLootCount($class, "total"), 2);                }        function getName(){        return $this->name;    }        function getLoot()    {           return $this->loot_count;    }    function display()    {        if(!isset($this->loot_count))            return;                $output = "<table>                <caption>Raid Statistics for " . $this->name . " </caption>        <thead>                <tr>                        <th scope=\"col\">Raids</th>                        <td>" . $this->getRaidCount() . "</td>                        <th>Tier 5</th>                        <th>Tier 6</th>                        <th>Tier 7</th>                        <th>Total</th>                        <th>Ratio</th>                        </tr>        </thead>                        <tfoot>        <tr><td>View Extra details</td></tr>        </tfoot>        <tbody>";                foreach($this->loot_count as $k => $v){                                        $output .= "<tr>                                <td colspan=\"2\" scope=\"col\">$k</td>                                <td>" . $this->getLootCount("$k","5") . "</td>                                <td>" . $this->getLootCount("$k","6") . "</td>                                <td>" . $this->getLootCount("$k","7") . "</td>                                <td>" . $this->getLootCount("$k","total") . "</td>                                <td>" . $this->getRatio("$k"). "</td>                        </tr>";                                                }         $output .= "</tbody><table>";        echo $output;    }}?>