/** * Internal function to connect to the DB and retrieve clients XLR bio Infomation */ private function getClientBio() { $db = DB_B3::getPointer(); // get the pointer to the current B3 connection global $cid; ## Get information for xlrstats ## $query_xlr = "SELECT id, kills, deaths, ratio, skill, rounds, hide, fixed_name FROM xlr_playerstats WHERE client_id = ? LIMIT 1"; $stmt = $db->mysql->prepare($query_xlr) or die('Database Error'); $stmt->bind_param('i', $cid); $stmt->execute(); $stmt->store_result(); if ($stmt->num_rows > 0) { $this->xlr_user = true; $stmt->bind_result($id, $kills, $deaths, $ratio, $skill, $rounds, $hide, $fixed_name); $stmt->fetch(); $results = array('id' => $id, 'kills' => $kills, 'deaths' => $deaths, 'ratio' => $ratio, 'skill' => $skill, 'rounds' => $rounds, 'hide' => $hide, 'fixed_name' => $fixed_name); $this->xlr_fixed_name = $fixed_name; $this->xlr_hide = $hide; } else { $this->xlr_user = false; } $stmt->free_result(); $stmt->close(); return $results; }
public function editSettings($tables, $names) { global $game; // current game id $dbl = DBL::getInstance(); // get Echelon db pointer $db = DB_B3::getPointer(); // get B3 Db pointer $tables_array = explode(',', $tables); foreach ($tables_array as $table) { // check each table exists $query = "SELECT id FROM {$table} LIMIT 1"; if (!($stmt = $db->mysql->prepare($query))) { // if table does not exist then prepare will fail return false; } // if not return false } // Update the tables row $result = $dbl->updateSettings($tables, 'chats_table_' . $game, 's'); if (!$result) { $result = $dbl->setSettings($tables, 'chats_table_' . $game, 's'); if (!$result) { return false; } } // update the names row $result = $dbl->updateSettings($names, 'chats_names_' . $game, 's'); if (!$result) { $result = $dbl->setSettings($names, 'chats_names_' . $game, 's'); if (!$result) { return false; } } return true; }
$i = 0; // start counter at 0 $total_overall_rows = 0; // set default value to 0 ## Loop thro the tables and retrieve the relevant data while ($i < $num_tables) { // write and preform query for each server // create query array $query = array(); $table_name = $tables[$i]; if (empty($table_name)) { $table_name = 'chatlog'; } // write query $query[$i] = "SELECT id, msg_time, msg_type, msg FROM {$table_name} WHERE client_id = {$cid} ORDER BY msg_time DESC LIMIT {$limit_rows}"; $db = DB_B3::getPointer(); // run query $results = $db->mysql->query($query[$i]) or die('DB Error'); while ($row = $results->fetch_object()) { $records[$i][] = array('id' => $row->id, 'msg_time' => $row->msg_time, 'msg_type' => $row->msg_type, 'msg' => $row->msg); } // find num of rows found $num_rows_[$i] = $results->num_rows; // start count on num of total overall rows $total_overall_rows = $total_overall_rows + $num_rows_[$i]; // keeps last loop number plus addition of this loops num_rows // add 1 to counter $i++; $results = NULL; } // end while looping thro all tables to find any records