本文整理汇总了PHP中DBAccess类的典型用法代码示例。如果您正苦于以下问题:PHP DBAccess类的具体用法?PHP DBAccess怎么用?PHP DBAccess使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DBAccess类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getUserInfo
public function getUserInfo()
{
$query = "SELECT * FROM usernames WHERE username = '" . $_POST['username'] . "' AND Password = '" . $_POST['password'] . "'";
$dbAccess = new DBAccess();
$select = $dbAccess->select($query);
return $select;
}
示例2: render_chat_messages
/**
* Render the div full of chat messages.
* @param $chatlength Essentially the limit on the number of messages.
**/
function render_chat_messages($chatlength, $show_elipsis = null)
{
// Eventually there might be a reason to abstract out get_chats();
$sql = new DBAccess();
$sql->Query("SELECT sender_id, uname, message, age(now(), date) as ago FROM chat join players on chat.sender_id = player_id ORDER BY chat_id DESC LIMIT {$chatlength}");
// Pull messages
$chats = $sql->fetchAll();
$message_rows = '';
$messageCount = $sql->QueryItem("select count(*) from chat");
if (!isset($show_elipsis) && $messageCount > $chatlength) {
$show_elipsis = true;
}
$res = "<div class='chatMessages'>";
$previous_date = null;
$skip_interval = 3;
// minutes
foreach ($chats as $messageData) {
$l_ago = time_ago($messageData['ago'], $previous_date);
$message_rows .= "<li><<a href='player.php?player_id={$messageData['sender_id']}'\n\t\t target='main'>{$messageData['uname']}</a>> " . out($messageData['message']) . " <span class='chat-time'>{$l_ago}</span></li>";
$previous_date = $messageData['ago'];
// Store just prior date.
}
$res .= $message_rows;
if ($show_elipsis) {
// to indicate there are more chats available
$res .= ".<br>.<br>.<br>";
}
$res .= "</div>";
return $res;
}
示例3: getDestinationCities
public function getDestinationCities()
{
$destinationCities = array();
$query = 'SELECT DISTINCT destino FROM rutas';
$dbAccess = new DBAccess();
$select = $dbAccess->select($query);
return $select;
}
示例4: getUserfullname
public function getUserfullname($username, $password)
{
session_start();
$query = "SELECT * FROM usernames WHERE username = '" . $username . "' AND Password = '" . $password . "'";
$dbAccess = new DBAccess();
$select = $dbAccess->select($query);
return $select;
}
示例5: update_last_attack_time
/**
* Attack function library.
* @package combat
* @subpackage lib_attack
**/
function update_last_attack_time($player_id, $sql = null)
{
if (!$sql) {
$sql = new DBAccess();
}
$update_last_attacked = "update players set last_started_attack=now() where player_id='" . intval($player_id) . "'";
$sql->Query($update_last_attacked);
// updates the timestamp of the last_attacked column to slow excessive attacks.
}
示例6: check_for_resurrection
function check_for_resurrection($echo = FALSE)
{
$dbObj = new DBAccess();
$dbObj->Update("UPDATE players\n SET status = 0,\n health = (CASE WHEN class='White' THEN (150+(level*3)) ELSE 100 END)\n WHERE confirmed = 1\n AND health < 0\n AND resurrection_time = (SELECT amount from time where time_label='hours')\n AND\n ( days<31 OR\n \t\t\t\t(\n \t\t\t\t\t((days %\n \t\t\t\t\t cast(floor(days / 10) AS integer))\n \t\t\t\t\t =0\n \t\t\t\t\t)\n \t\t\t\t)\n \t\t\t)\n ");
// *** Resurrect and heal all players at this countdown spot.
if ($echo) {
$healedPlayers = $dbObj->a_rows;
echo "Number of healed/resurrected players: " . $healedPlayers;
}
}
示例7: __construct
public function __construct($player_id_or_username)
{
$sql = new DBAccess();
if (!is_numeric($player_id_or_username)) {
$sel = "select player_id from players where uname = '" . $player_id_or_username . "' limit 1";
$this->player_id = $sql->QueryItem($sel);
} else {
$this->player_id = $player_id_or_username;
}
$dao = new PlayerDAO($sql);
$this->vo = $dao->get($this->player_id);
}
示例8: render_active
function render_active($limit = 5, $alive_only = true)
{
$where_cond = $alive_only ? 'and health>0' : '';
$sel = "select uname, player_id from players where confirmed=1 {$where_cond} order by last_started_attack desc limit {$limit}";
$sql = new DBAccess();
$res = $sql->QueryAssoc($sel);
$out = "\n <div class='active-players'>\n <ul>\n <li><span>Lurking ninja: </span></li>\n\t";
foreach ($res as $ninja) {
$out .= " <li class='active-ninja'><a href='player.php?target_id=" . $ninja['player_id'] . "'>" . $ninja['uname'] . "</a></li>";
}
$out .= "\n </ul>\n </div>\n ";
return $out;
}
示例9: clan_size
/**
* This determines how the clans get ranked and tagged, and how to only show non-empty clans.
**/
function clan_size()
{
$res = array();
$db = new DBAccess();
$sel = "select sum(level-3-round(days/5)) as sum, clan_long_name from players where confirmed = 1 group by clan_long_name order by sum desc";
$counts = $db->FetchAll($sel);
$largest = reset($counts);
$max = $largest['sum'];
foreach ($counts as $clan_info) {
// make percentage of highest, multiply by 10 and round to give a 1-10 size
$res[$clan_info['clan_long_name']] = floor(($clan_info['sum'] - 1 < 1 ? 0 : $clan_info['sum'] - 1) / $max * 10) + 1;
}
return $res;
}
示例10: json_index
function json_index()
{
$sql = new DBAccess();
$player = get_player_info();
$events = array();
$messages = array();
$user_id = $player['player_id'];
if ($user_id) {
$events = $sql->FetchAll("select event_id, message as event, date, send_to, send_from, unread, uname as sender from events join players on player_id = send_from where send_to = '" . sql($user_id) . "' order by date desc limit 1");
//$chats = $sql->FetchAll("select * from chat order by time desc");
$messages = $sql->FetchAll("select message_id, message, date, send_to, send_from, unread, uname as sender from messages join players on player_id = send_from where send_to = '" . sql($user_id) . "' and send_from != '" . sql($user_id) . "' order by date desc limit 1");
}
return '{"player":' . json_encode($player) . ',"message":' . json_encode(reset($messages)) . ',"event":' . json_encode(reset($events)) . '}';
}
示例11: display
function display($tpl = null)
{
global $mainframe, $option;
$mainframe = JFactory::getApplication();
$db = JFactory::getDBO();
$search = $mainframe->getUserStateFromRequest("{$option}.search", 'search', '', 'string');
if (strpos($search, '"') !== false) {
$search = str_replace(array('=', '<'), '', $search);
}
$search = JString::strtolower($search);
$limit = $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int');
$limitstart = $mainframe->getUserStateFromRequest($option . '.limitstart', 'limitstart', 0, 'int');
// echo $limitstart;
// echo $limit;
$where = array();
if ($search) {
$where[] = 'LOWER(pn_poly_name) LIKE ' . $db->Quote('%' . $db->getEscaped($search, true) . '%', false);
}
$where = count($where) ? ' WHERE ' . implode(' AND ', $where) : '';
// if($limiter || $limit) {
$limiter = ' LIMIT ' . $limitstart . ', ' . $limit;
// }
$mysqli = DBAccess::getConnection();
$query = 'SELECT * from pn_lenses_polymers';
$result = $mysqli->selectQuery($query);
$total = $result->num_rows;
// echo $total;
jimport('joomla.html.pagination');
$pagination = new JPagination($total, $limitstart, $limit);
//$mysqli = new mysqli(self::GPHOST, self::GPUSER, self::GPPASS, self::GPDB);
$query = 'SELECT * from pn_lenses_polymers ' . $where . ' ORDER BY pn_poly_name' . $limiter;
$result = $mysqli->selectQuery($query);
while ($obj = $result->fetch_object()) {
$polymers[] = $obj;
}
foreach ($polymers as $poly) {
switch ($poly->pn_fda_grp) {
case 1:
$poly->pn_fda_grp = 'Low Water (<50 percent water content), Nonionic Polymers.<br />This group has the greatest resistance to protein deposition due
to its lower water content and nonionic nature. Heat, chemical, and hydrogen peroxide care regimens can be used.';
break;
case 2:
$poly->pn_fda_grp = 'High Water (greater than 50 percent water content), Nonionic Polymers.<br />The higher water content of this group results in g
reater protein attraction than with group 1. However, the nonionic polymers reduce the potential for further attraction. Heat disinfection should be a
voided because of the high water content. In addition, sorbic acid and potassium sorbate preservatives can discolor the lenses.';
break;
case 3:
$poly->pn_fda_grp = 'Low Water (less then 50 percent water content), Ionic Polymers.<br />The lower water content but ionic nature of these polymers
results in intermediate protein resistance. Heat, chemical and hydrogen peroxide care systems may be used.';
break;
case 4:
$poly->pn_fda_grp = 'High Water (greater then 50 percent water content), Ionic Polymers.<br />Because of the high water content and ionic nature of
these polymers they attract more proteins than any other group. It is best to avoid heat disinfection and sorbic acid preservatives.';
break;
}
}
$this->assignRef('polymers', $polymers);
$this->assignRef('pagination', $pagination);
parent::display($tpl);
}
示例12: getConnection
public static function getConnection()
{
if (is_null(self::$_dbinstance)) {
self::$_dbinstance = new DBAccess();
}
return self::$_dbinstance;
}
示例13: getDbAccessor
private static function getDbAccessor()
{
if (self::$_dbAccessor == null) {
self::$_dbAccessor = new DBAccessor();
}
return self::$_dbAccessor;
}
示例14: delete_mail
/**
* Delete an array of ids or all mail for a certain user.
**/
function delete_mail($ids, $all = false)
{
$sql = new DBAccess();
$deleted = 0;
$username = get_username();
if ($all) {
// Delete all a user's mail.
$del = "DELETE from mail where send_to='" . $username . "'";
} else {
// Delete an id list.
$del = "DELETE from mail where send_to='" . $username . "'\n AND id in ('" . implode("', '", $ids) . "')";
}
$sql->Delete($del);
$deleted = $sql->a_rows;
return $deleted;
}
示例15: get_player_info
/**
* Returns the state of the player from the database,
* uses a user_id if one is present, otherwise
* defaults to the currently logged in player, but can act on any player
* if another username is passed in.
* @param $user user_id or username
* @param @password Unless true, wipe the password.
**/
function get_player_info($user = null, $password = false)
{
$sql = new DBAccess();
$player_data = null;
if (is_numeric($user)) {
$sel_player = "select * from players where player_id = '" . $user . "' limit 1";
} else {
$username = either($user, SESSION::is_set('username') ? SESSION::get('username') : null);
// Default to current session user.
$sel_player = "select * from players where uname = '" . sql($username) . "' limit 1";
}
$player_data = $sql->QueryRowAssoc($sel_player);
if (!$password) {
unset($player_data['pname']);
}
return $player_data;
}