/** * read the object information from the db */ private function load($id) { $db = new DB(); $sql = "SELECT pt.idgame, pt.title, pp.idplayer, pt.d, pt.sb, pt.bb, pt.seats, pt.blind, pt.iduser, pt.idspot\n FROM poker_tables AS pt\n LEFT JOIN poker_players AS pp ON (pp.idtable = pt.idtable AND pp.pactive = 1)\n WHERE pt.idtable = '{$id}'\n ORDER BY pp.position"; $result = $db->query($sql); if ($result->length() > 0) { $players = array(); if ($result->idplayer != '') { $prev = false; do { $player = PokerPlayer::getInstance($result->idplayer); $player->prev = $prev; if (is_object($prev)) { $prev->next = $player; } $players[$player->position] = $player; $prev = $player; } while ($result->next()); $first = reset($players); $first->prev = $prev; $prev->next = $first; } // general information $this->info = array("game" => $result->idgame != 0 && $result->idgame != '' ? Poker::getInstance($result->idgame) : FALSE, "spot" => $result->idspot != 0 && $result->idspot != '' ? PokerSpot::getInstance($result->idspot) : FALSE, 'title' => $result->title, 'players' => $players, 'positions' => array('smallblind' => $result->sb, 'bigblind' => $result->bb, 'dealer' => $result->d), 'blinds' => array('big' => 2 * $result->blind, 'small' => $result->blind), 'seats' => $result->seats, 'user' => $result->iduser); $this->info['free'] = $this->info['seats'] - count($this->info['players']); $this->id = $id; return true; } return false; }
/** * read the object information from the db */ private function load($id) { $db = new DB(); $sql = "SELECT pa.idgame, pa.action, pa.params, pa.idtable, pa.idplayer, UNIX_TIMESTAMP(pa.timestamp) AS timestamp\n FROM poker_actions AS pa \n WHERE pa.idaction = '{$id}'"; $result = $db->query($sql); if ($result->length() > 0) { // general information $this->info = array("action" => $result->action, 'params' => unserialize($result->params), 'player' => $result->idplayer != '' && $result->idplayer != 0 ? PokerPlayer::getInstance($result->idplayer) : false, 'game' => Poker::getInstance($result->idgame), 'table' => PokerTable::getInstance($result->idtable), 'time' => $result->timestamp); $this->id = $id; return true; } return false; }