當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DBAccess類代碼示例

本文整理匯總了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;
 }
開發者ID:KacosPro,項目名稱:adm-buses,代碼行數:7,代碼來源:users.php

示例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>&lt;<a href='player.php?player_id={$messageData['sender_id']}'\n\t\t     target='main'>{$messageData['uname']}</a>&gt; " . 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;
}
開發者ID:ninjajerry,項目名稱:ninjawars,代碼行數:34,代碼來源:lib_chat.php

示例3: getDestinationCities

 public function getDestinationCities()
 {
     $destinationCities = array();
     $query = 'SELECT DISTINCT destino FROM rutas';
     $dbAccess = new DBAccess();
     $select = $dbAccess->select($query);
     return $select;
 }
開發者ID:KacosPro,項目名稱:adm-buses,代碼行數:8,代碼來源:routes.php

示例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;
 }
開發者ID:KacosPro,項目名稱:adm-buses,代碼行數:8,代碼來源:user-fullname.php

示例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.
}
開發者ID:ninjajerry,項目名稱:ninjawars,代碼行數:14,代碼來源:lib_attack.php

示例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;
    }
}
開發者ID:ninjajerry,項目名稱:ninjawars,代碼行數:10,代碼來源:check_for_resurrection.php

示例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);
 }
開發者ID:ninjajerry,項目名稱:ninjawars,代碼行數:12,代碼來源:Player.class.php

示例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;
}
開發者ID:ninjajerry,項目名稱:ninjawars,代碼行數:13,代碼來源:lib_player_list.php

示例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;
}
開發者ID:ninjajerry,項目名稱:ninjawars,代碼行數:17,代碼來源:lib_tags.php

示例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)) . '}';
}
開發者ID:ninjajerry,項目名稱:ninjawars,代碼行數:14,代碼來源:api.php

示例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);
    }
開發者ID:grlf,項目名稱:eyedock,代碼行數:60,代碼來源:view.html.php

示例12: getConnection

 public static function getConnection()
 {
     if (is_null(self::$_dbinstance)) {
         self::$_dbinstance = new DBAccess();
     }
     return self::$_dbinstance;
 }
開發者ID:grlf,項目名稱:eyedock,代碼行數:7,代碼來源:mysqliSingleton.php

示例13: getDbAccessor

 private static function getDbAccessor()
 {
     if (self::$_dbAccessor == null) {
         self::$_dbAccessor = new DBAccessor();
     }
     return self::$_dbAccessor;
 }
開發者ID:vin100zz,項目名稱:mesautos,代碼行數:7,代碼來源:db.php

示例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;
}
開發者ID:ninjajerry,項目名稱:ninjawars,代碼行數:19,代碼來源:lib_mail.php

示例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;
}
開發者ID:ninjajerry,項目名稱:ninjawars,代碼行數:25,代碼來源:lib_header.php


注:本文中的DBAccess類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。