本文整理汇总了PHP中SQL::connect方法的典型用法代码示例。如果您正苦于以下问题:PHP SQL::connect方法的具体用法?PHP SQL::connect怎么用?PHP SQL::connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SQL
的用法示例。
在下文中一共展示了SQL::connect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: forum_do_edit_stick
function forum_do_edit_stick(&$sqlm)
{
global $forum_lang, $user_lvl, $mmfpm_db;
$sqlm = new SQL();
$sqlm->connect($mmfpm_db['addr'], $mmfpm_db['user'], $mmfpm_db['pass'], $mmfpm_db['name']);
if ($user_lvl == 0) {
error($forum_lang['no_access']);
}
if (!isset($_GET['id'])) {
error($forum_lang['no_such_topic']);
} else {
$id = $sqlm->quote_smart($_GET['id']);
}
if (!isset($_GET['state'])) {
error('Bad request, please mail admin and describe what you did to get this error.');
} else {
$state = $sqlm->quote_smart($_GET['state']);
}
$sqlm->query('
UPDATE mm_forum_posts
SET sticked = ' . $state . '
WHERE id = ' . $id . '');
$sqlm->close();
redirect('forum.php?action=view_topic&id=' . $id . '');
// Queries : 1
}
示例2: get_additional_data
/**
* calculate creature health, mana and armor
*
* kinda crappy way, but works
*
* if $type is used:
* 1 -> returns health
* 2 -> returns mana
* 3 -> returns armor
* 0 -> returns array(health,mana,armor)
*/
function get_additional_data($entryid, $type = 0)
{
global $world_db, $realm_id;
if (!is_numeric($entryid)) {
return array(0, 0, 0);
}
$sqlw = new SQL();
$sqlw->connect($world_db[$realm_id]['addr'], $world_db[$realm_id]['user'], $world_db[$realm_id]['pass'], $world_db[$realm_id]['name']);
$q = $sqlw->query("\n\t\tSELECT \n\t\t\t(SELECT unit_class \n\t\t\tFROM creature_template \n\t\t\tWHERE entry = " . $entryid . ") AS class, \n\t\t\t\t(SELECT FLOOR(minlevel + (RAND() * (maxlevel - minlevel + 1))) \n\t\t\t\tFROM creature_template \n\t\t\t\tWHERE entry = " . $entryid . ") AS level, \n\t\t\t\t(SELECT exp \n\t\t\t\tFROM creature_template \n\t\t\t\tWHERE entry = " . $entryid . ") AS exp;");
$data = $sqlw->fetch_assoc($q);
if ($sqlw->num_rows($q) == 0) {
return array(0, 0, 0);
}
$q = "\n\t\t\tSELECT \n\t\t\t\t((SELECT Health_Mod \n\t\t\t\tFROM creature_template \n\t\t\t\tWHERE entry = " . $entryid . ")\n\t\t\t\t\t*(SELECT basehp" . $data['exp'] . " \n\t\t\t\t\tFROM creature_classlevelstats \n\t\t\t\t\tWHERE level = " . $data['level'] . " AND class = " . $data['class'] . ")+0.5), \n\t\t\t\t((SELECT Mana_Mod \n\t\t\t\tFROM creature_template \n\t\t\t\tWHERE entry = " . $entryid . ")\n\t\t\t\t\t*(SELECT basemana \n\t\t\t\t\tFROM creature_classlevelstats \n\t\t\t\t\tWHERE level = " . $data['level'] . " AND class = " . $data['class'] . ")+0.5),\n\t\t\t\t((SELECT Armor_Mod \n\t\t\t\tFROM creature_template \n\t\t\t\tWHERE entry = " . $entryid . ")\n\t\t\t\t*(SELECT basearmor \n\t\t\t\tFROM creature_classlevelstats \n\t\t\t\tWHERE level = " . $data['level'] . " AND class = " . $data['class'] . ")+0.5);";
if ($type == 1) {
$q = "\n\t\t\tSELECT \n\t\t\t\t((SELECT Health_Mod \n\t\t\t\tFROM creature_template \n\t\t\t\tWHERE entry = " . $entryid . ")\n\t\t\t\t\t*(SELECT basehp" . $data['exp'] . " \n\t\t\t\t\tFROM creature_classlevelstats \n\t\t\t\t\tWHERE level = " . $data['level'] . " AND class = " . $data['class'] . ")+0.5);";
}
if ($type == 2) {
$q = "\n\t\t\tSELECT \n\t\t\t\t((SELECT Mana_Mod \n\t\t\t\tFROM creature_template \n\t\t\t\tWHERE entry = " . $entryid . ")\n\t\t\t\t\t*(SELECT basemana \n\t\t\t\t\tFROM creature_classlevelstats \n\t\t\t\t\tWHERE level = " . $data['level'] . " AND class = " . $data['class'] . ")+0.5);";
}
if ($type == 3) {
$q = "\n\t\t\tSELECT \n\t\t\t\t((SELECT Armor_Mod \n\t\t\t\tFROM creature_template \n\t\t\t\tWHERE entry = " . $entryid . ")\n\t\t\t\t\t*(SELECT basearmor \n\t\t\t\t\tFROM creature_classlevelstats \n\t\t\t\t\tWHERE level = " . $data['level'] . " AND class = " . $data['class'] . ")+0.5);";
}
$query = $sqlw->query($q);
$result = $sqlw->fetch_row($query);
$sqlw->close();
unset($sql);
if ($type == 2 && $result[0] == 0.5) {
return 0;
}
if ($type == 0 && $result[1] == 0.5) {
return array($result[0], 0, $result[2]);
}
return $type > 0 ? $result[0] : $result;
}
示例3: get_realm_name
function get_realm_name($realm_id)
{
global $realm_db;
$sqlr = new SQL();
$sqlr->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']);
$result = $sqlr->query("SELECT name FROM `realmlist` WHERE id = '{$realm_id}'");
$realm_name = $sqlr->result($result, 0);
return $realm_name;
}
示例4: deleteKategorien
/**
* Delete a Categorie in DB
* parameters = POST: Categorie ID
*/
public function deleteKategorien()
{
require 'classes/SQL.php';
$sql = new SQL();
$sql->connect();
$id = mysql_real_escape_string($_POST['id']);
if (is_numeric($id)) {
$sql->doThat('DELETE FROM quizCategories WHERE id=' . $id);
}
}
示例5: deleteQuestion
/**
* Remove Question in DB
* parameters = POST: QuestionID
*/
public function deleteQuestion()
{
require 'classes/SQL.php';
$sql = new SQL();
$sql->connect();
$id = mysql_real_escape_string($_POST['id']);
if (is_numeric($gameID)) {
$sql->doThat('DELETE FROM quizQuestions WHERE id=' . mysql_real_escape_string($id));
}
}
示例6: search
function search()
{
global $lang_global, $lang_mail, $output, $itemperpage, $item_datasite, $mangos_db, $characters_db, $realm_id, $sql_search_limit;
wowhead_tt();
if (!isset($_GET['search_value']) || !isset($_GET['search_by'])) {
redirect("mail_on.php?error=2");
}
$sql = new SQL();
$sql->connect($characters_db[$realm_id]['addr'], $characters_db[$realm_id]['user'], $characters_db[$realm_id]['pass'], $characters_db[$realm_id]['name']);
$search_value = $sql->quote_smart($_GET['search_value']);
$search_by = $sql->quote_smart($_GET['search_by']);
$search_menu = array('sender', 'receiver');
// if (!array_key_exists($search_by, $search_menu)) $search_by = 'sender';
$start = isset($_GET['start']) ? $sql->quote_smart($_GET['start']) : 0;
$order_by = isset($_GET['order_by']) ? $sql->quote_smart($_GET['order_by']) : "id";
$dir = isset($_GET['dir']) ? $sql->quote_smart($_GET['dir']) : 1;
$order_dir = $dir ? "ASC" : "DESC";
$dir = $dir ? 0 : 1;
$temp = $sql->query("SELECT guid FROM `characters` WHERE name like '%{$search_value}%'");
$search_value = $sql->result($temp, 0, 'guid');
$query_1 = $sql->query("SELECT count(*) FROM `mail`");
$query = $sql->query("SELECT a.id, a.messageType, a.sender, a.receiver, a.subject, a.itemTextId, a.has_items, a.money, a.cod, a.checked, b.item_template\r\n FROM mail a\r\n INNER JOIN mail_items b ON a.id = b.mail_id\r\n WHERE {$search_by} = {$search_value}\r\n ORDER BY {$order_by} {$order_dir} LIMIT {$start}, {$itemperpage}");
$this_page = $sql->num_rows($query);
$all_record = $sql->result($query_1, 0);
$total_found = $sql->num_rows($query);
//==========================top page navigation starts here========================
$output .= "<center><table class=\"top_hidden\">\r\n <tr><td>\r\n <table class=\"hidden\">\r\n <tr><td>\r\n <form action=\"mail_on.php\" method=\"get\" name=\"form\">\r\n <input type=\"hidden\" name=\"action\" value=\"search\" />\r\n <input type=\"hidden\" name=\"error\" value=\"4\" />\r\n <input type=\"text\" size=\"45\" name=\"search_value\" />\r\n <select name=\"search_by\">\r\n <option value=\"sender\">Sender</option>\r\n <option value=\"receiver\">Receiver</option>\r\n </select></form></td><td>";
makebutton($lang_global['search'], "javascript:do_submit()", 80);
$output .= "</td></tr></table>\r\n <td align=\"right\">";
$output .= generate_pagination("mail_on.php?action=search&order_by={$order_by}&dir=" . !$dir, $all_record, $itemperpage, $start);
$output .= "</td></tr></table>";
//==========================top page navigation ENDS here ========================
$output .= "<table class=\"lined\">\r\n <tr>\r\n <th width=\"5%\">" . $lang_mail['id'] . "</th>\r\n <th width=\"5%\">" . $lang_mail['mail_type'] . "</th>\r\n <th width=\"10%\">" . $lang_mail['sender'] . "</th>\r\n <th width=\"10%\">" . $lang_mail['receiver'] . "</th>\r\n <th width=\"15%\">" . $lang_mail['subject'] . "</th>\r\n <th width=\"5%\">" . $lang_mail['has_items'] . "</th>\r\n <th width=\"25%\">" . $lang_mail['text'] . "</th>\r\n <th width=\"20%\">" . $lang_mail['money'] . "</th>\r\n <th width=\"5%\">" . $lang_mail['checked'] . "</th>\r\n </tr>";
while ($mail = $sql->fetch_array($query)) {
$g = floor($mail[7] / 10000);
$mail[7] -= $g * 10000;
$s = floor($mail[7] / 100);
$mail[7] -= $s * 100;
$c = $mail[7];
$money = "";
if ($mail[7] > 0) {
$money = $g . "<img src=\"./img/gold.gif\" /> " . $s . "<img src=\"./img/silver.gif\" /> " . $c . "<img src=\"./img/copper.gif\" /> ";
}
$output .= "<tr valign=top>\r\n <td>{$mail['0']}</td>\r\n <td>" . get_mail_source($mail[1]) . "</td>\r\n <td><a href=\"char.php?id={$mail['2']}\">" . get_char_name($mail[2]) . "</a></td>\r\n <td><a href=\"char.php?id={$mail['3']}\">" . get_char_name($mail[3]) . "</a></td>\r\n <td>{$mail['4']}</td>\r\n ";
$output .= "<td>";
$output .= "\r\n <a style=\"padding:2px;\" href=\"{$item_datasite}{$mail[10]}\" target=\"_blank\">\r\n <img class=\"bag_icon\" src=\"" . get_item_icon($mail[10]) . "\" alt=\"\" />\r\n </a>";
//maketooltip("<img src=\"./img/up.gif\" alt=\"\">", $item_datasite{$mail[10]}, $mail[10], "item_tooltip", "target=\"_blank\"");
$output .= "</td>";
$output .= "<td>" . get_mail_text($mail[5]) . "</td>\r\n <td>{$money}</td>\r\n <td>" . get_check_state($mail[9]) . "</td>\r\n </tr>";
}
/*--------------------------------------------------*/
$output .= "<tr><td colspan=\"6\" class=\"hidden\" align=\"right\">All Mails: {$all_record}</td></tr>\r\n </table></center>";
$sql->close();
}
示例7: getModel
/**
* Return Data-Model for the View
*/
private function getModel()
{
require_once 'classes/SQL.php';
$model = new stdClass();
$model->template = 'admin/HighscoreTable';
$model->isAdmin = person::getPermissionName() == 'admin' ? 'true' : 'false';
$model->gameID = $this->getGameId();
$sql = new SQL();
$sql->connect();
$model->data = $sql->get("SELECT * FROM ViewHighscore ORDER BY GamerMainScore DESC");
return $model;
}
示例8: connect
function connect()
{
if ($this->isConnected) {
return;
}
parent::connect();
$this->version = floatval($this->pdo->getAttribute(\PDO::ATTR_SERVER_VERSION));
if ($this->version < 9) {
$this->separator = '),';
$this->agg = 'array_to_string(array_agg';
}
}
示例9: get_mail_text
function get_mail_text($id)
{
global $characters_db, $realm_id;
if ($id) {
$sqlc = new SQL();
$sqlc->connect($characters_db[$realm_id]['addr'], $characters_db[$realm_id]['user'], $characters_db[$realm_id]['pass'], $characters_db[$realm_id]['name']);
$result = $sqlc->query("SELECT `body` FROM `mail` WHERE `id` = '{$id}'");
$text_subject = $sqlc->result($result, 0);
return $text_subject;
} else {
return NULL;
}
}
示例10: get_char_name
function get_char_name($id)
{
global $characters_db, $realm_id;
if ($id) {
$sqlc = new SQL();
$sqlc->connect($characters_db[$realm_id]['addr'], $characters_db[$realm_id]['user'], $characters_db[$realm_id]['pass'], $characters_db[$realm_id]['name']);
$result = $sqlc->query("SELECT `name` FROM `characters` WHERE `guid` = '{$id}'");
$player_name = $sqlc->result($result, 0);
return $player_name;
} else {
return NULL;
}
}
示例11: dologin
function dologin(&$sqlr)
{
global $mmfpm_db, $require_account_verify;
if (empty($_POST['user']) || empty($_POST['pass'])) {
redirect('login.php?error=2');
}
$user_name = $sqlr->quote_smart($_POST['user']);
$user_pass = $sqlr->quote_smart($_POST['pass']);
if (255 < strlen($user_name) || 255 < strlen($user_pass)) {
redirect('login.php?error=1');
}
$result = $sqlr->query('SELECT id, username
FROM account
WHERE username = \'' . $user_name . '\' AND sha_pass_hash = \'' . $user_pass . '\'');
$result2 = $sqlr->query('SELECT id, gmlevel FROM account_access');
if ($require_account_verify) {
$sqlm = new SQL();
$sqlm->connect($mmfpm_db['addr'], $mmfpm_db['user'], $mmfpm_db['pass'], $mmfpm_db['name']);
$result2 = $sqlm->query("SELECT * \n\t\t\t\t\t\t\t\t\tFROM mm_account_verification \n\t\t\t\t\t\t\t\t\tWHERE username = '{$user_name}'");
if ($sqlm->num_rows($result2) >= 1) {
$sqlm->close;
redirect('login.php?error=7');
}
}
unset($user_name);
if (1 == $sqlr->num_rows($result)) {
$id = $sqlr->result($result, 0, 'id');
if ($sqlr->result($sqlr->query('SELECT count(*) FROM account_banned WHERE id = ' . $id . ' AND active = \'1\''), 0)) {
redirect('login.php?error=3');
} else {
$_SESSION['user_id'] = $id;
$_SESSION['uname'] = $sqlr->result($result, 0, 'username');
if ($sqlr->result($result2, 0, 'gmlevel') == null) {
$_SESSION['user_lvl'] = 0;
} else {
$_SESSION['user_lvl'] = $sqlr->result($result2, 0, 'gmlevel');
}
$_SESSION['realm_id'] = $sqlr->quote_smart($_POST['realm']);
$_SESSION['client_ip'] = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : getenv('REMOTE_ADDR');
$_SESSION['logged_in'] = true;
if (isset($_POST['remember']) && $_POST['remember'] != '') {
setcookie('uname', $_SESSION['uname'], time() + 60 * 60 * 24 * 7);
setcookie('realm_id', $_SESSION['realm_id'], time() + 60 * 60 * 24 * 7);
setcookie('p_hash', $user_pass, time() + 60 * 60 * 24 * 7);
}
redirect('index.php');
}
} else {
redirect('login.php?error=1');
}
}
示例12: getListProduit
function getListProduit()
{
$sql = new SQL();
$sql->connect();
$sql->exe_select("select * from produit");
$items = array();
for ($i = 1; $i <= $sql->nbresult(); $i++) {
$produit = new Produit();
$produit->__set('idProduit', $sql->recup($i, 'ID_PRODUIT'));
$produit->__set('libelle', $sql->recup($i, 'LIBELLE'));
$items[] = $produit;
}
return $items;
}
示例13: uptime
function uptime()
{
global $realm, $realmd_host, $realmd_user, $realmd_pass, $realmd_db;
$id = $realm['id'];
$sqlr = new SQL();
$sqlr->connect($realmd_host, $realmd_user, $realmd_pass, $realmd_db);
$query = $sqlr->query("SELECT uptime FROM uptime WHERE realmid='{$id}'");
$result = mysql_fetch_assoc($query);
$up = $result['uptime'];
$secs = intval($up % 60);
$mins = intval($up / 60 % 60);
$hours = intval($up / 3600 % 24);
$days = intval($up / 86400);
return $days . " days " . $hours . " hours " . $mins . " minutes " . $secs . " seconds";
}
示例14: del_guild
function del_guild()
{
global $lang_guild, $lang_global, $output, $characters_db, $realm_id, $realm_db, $action_permission, $user_lvl, $user_id;
$sqlr = new SQL();
$sqlr->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']);
if (empty($_GET['realm'])) {
$realmid = $realm_id;
} else {
$realmid = $sqlr->quote_smart($_GET['realm']);
if (!is_numeric($realmid)) {
$realmid = $realm_id;
}
}
if (isset($_GET['id'])) {
$id = $_GET['id'];
} else {
redirect("guild.php?error=1&realm={$realmid}");
}
if (is_numeric($id)) {
} else {
redirect("guild.php?error=5&realm={$realmid}");
}
$sqlc = new SQL();
$sqlc->connect($characters_db[$realmid]['addr'], $characters_db[$realmid]['user'], $characters_db[$realmid]['pass'], $characters_db[$realmid]['name']);
$q_amIguildleader = $sqlc->query("select 1 from guild where guildid = '{$id}' and leaderguid in (select guid from characters where account = '{$user_id}')");
$amIguildleader = $sqlc->result($q_amIguildleader, 0, '1');
if ($user_lvl < $action_permission['delete'] && !$amIguildleader) {
redirect("guild.php?error=6&realm={$realmid}");
}
$output .= "\r\n <center>\r\n <h1><font class=\"error\">{$lang_global['are_you_sure']}</font></h1>\r\n <br />\r\n <font class=\"bold\">{$lang_guild['guild_id']}: {$id} {$lang_global['will_be_erased']}</font>\r\n <br /><br />\r\n <form action=\"cleanup.php?action=docleanup\" method=\"post\" name=\"form\">\r\n <input type=\"hidden\" name=\"type\" value=\"guild\" />\r\n <input type=\"hidden\" name=\"check\" value=\"-{$id}\" />\r\n <input type=\"hidden\" name=\"override\" value=\"1\" />\r\n <table class=\"hidden\">\r\n <tr>\r\n <td>";
makebutton($lang_global['yes'], "javascript:do_submit()\" type=\"wrn", 130);
$output .= "\r\n </td>\r\n <td>";
makebutton($lang_global['no'], "guild.php?action=view_guild&realm={$realmid}&id={$id}\" type=\"def", 130);
$output .= '
</td>
</tr>
</table>
</form>
</center>
<br />';
}
示例15: while
// we check how many realms are configured, this does not check if config is valid
if (1 < $sqlr->num_rows($result) && 1 < count($server) && 1 < count($characters_db)) {
$output .= '
<li><a href="#">' . $lang_header['realms'] . '</a></li>';
while ($realm = $sqlr->fetch_assoc($result)) {
if (isset($server[$realm['id']])) {
$set = $realm_id === $realm['id'] ? '>' : '';
$output .= '
<li><a href="realm.php?action=set_def_realm&id=' . $realm['id'] . '&url=' . $_SERVER['PHP_SELF'] . '">' . htmlentities($set . ' ' . $realm['name']) . '</a></li>';
}
}
unset($set);
unset($realm);
}
$sqlc = new SQL();
$sqlc->connect($characters_db[$realm_id]['addr'], $characters_db[$realm_id]['user'], $characters_db[$realm_id]['pass'], $characters_db[$realm_id]['name']);
// we have a different menu for guest account
if ($allow_anony && empty($_SESSION['logged_in'])) {
$lang_login = lang_login();
$output .= '
<li><a href="#">' . $lang_header['account'] . '</a></li>
<li><a href="register.php">' . $lang_login['not_registrated'] . '</a></li>
<li><a href="login.php">' . $lang_login['login'] . '</a></li>';
unset($lang_login);
} else {
$result = $sqlc->query('SELECT guid, name, race, class, level, gender
FROM characters
WHERE account = ' . $user_id . '');
// this puts links to user characters of active realm in "My Account" menu
if ($sqlc->num_rows($result)) {
$output .= '