本文整理汇总了PHP中DB::setColPrefix方法的典型用法代码示例。如果您正苦于以下问题:PHP DB::setColPrefix方法的具体用法?PHP DB::setColPrefix怎么用?PHP DB::setColPrefix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DB
的用法示例。
在下文中一共展示了DB::setColPrefix方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
function update()
{
$db = new DB("pref");
$db->setColPrefix("pref_");
foreach ($this->_vars as $name => $value) {
$db->value = $value;
$db->update("pref_name = '" . $name . "' AND pref_target = '" . $db->escape($this->target) . "'");
}
}
示例2: getLastMsg
function getLastMsg($uid)
{
$db = new DB("messages");
$db->setColPrefix("message_");
$db->setSort("message_added DESC");
$db->select("message_sender = '" . USER_ID . "' AND message_receiver = '" . $uid . "' OR message_sender = '" . $uid . "' AND message_receiver = '" . USER_ID . "'");
$db->nextRecord();
return array("added" => $db->added);
}
示例3: addLog
function addLog($user, $msg)
{
$db = new DB("users_log");
$db->setColPrefix("log_");
$db->user = $user;
$db->poster = USER_ID;
$db->added = time();
$db->msg = $msg;
$db->insert();
}
示例4: load
/**
* Load notifications
* @param type $limit
*/
function load($limit = 5)
{
$db = new DB("notifications");
$db->setColPrefix("notification_");
$db->setSort("notification_added DESC");
if (intval($limit)) {
$db->setLimit($limit);
}
$db->select("notification_user = '" . USER_ID . "'");
if ($db->numRows()) {
$return = "";
while ($db->nextRecord()) {
$return .= "<li>";
switch ($db->type) {
case 'friend':
$data = json_decode($db->data);
$user = new Acl($data->user);
switch ($data->type) {
case 'accept':
$return .= "<b><a href='" . page("profile", "view", $user->name) . "'>" . $user->name . "</a></b> <small>" . get_date($db->added) . "</small> <br /> " . _t("Has accepted your friend request");
break;
case 'decline':
$return .= "<b><a href='" . page("profile", "view", $user->name) . "'>" . $user->name . "</a></b> <small>" . get_date($db->added) . "</small> <br /> " . _t("Has declined your friend request");
break;
case 'remove':
$return .= "<b><a href='" . page("profile", "view", $user->name) . "'>" . $user->name . "</a></b> <small>" . get_date($db->added) . "</small> <br /> " . _t("Has removed you from his friends list");
break;
}
break;
case 'system':
$data = json_decode($db->data);
$group = new DB("groups");
$group->setColPrefix("group_");
$group->select("group_id = '" . $data->group . "'");
$group->nextRecord();
switch ($data->type) {
case 'upgrade':
$return .= _t("You have been upgraded to ") . "<b>" . $group->name . "</b><br /><small>" . get_date($db->added) . "</small>";
break;
case 'downgrade':
$return .= _t("You have been demoted to ") . "<b>" . $group->name . "</b><br /><small>" . get_date($db->added) . "</small>";
break;
}
break;
}
$return .= "</li>";
}
} else {
$return = "<li>" . _t("No notifications found") . "</li>";
}
echo $return;
}
示例5: update
/**
* Update the pref values on the selected target.
*/
function update()
{
$db = new DB("pref");
$db->setColPrefix("pref_");
foreach ($this->_vars as $name => $value) {
$db->select("pref_name = '" . $name . "' AND pref_target = '" . $db->escape($this->target) . "'");
if ($db->numRows()) {
$db->value = $value;
$db->update("pref_name = '" . $name . "' AND pref_target = '" . $db->escape($this->target) . "'");
} else {
$db->name = $name;
$db->value = $value;
$db->target = $this->target;
$db->insert();
}
}
}
示例6: build
/**
* Build the navigation
* @return string
*/
function build()
{
$db = new DB("navigations");
$db->setColPrefix("navigation_");
$db->setSort("navigation_sorting ASC");
$db->select("navigation_lang = '" . CURRENT_LANGUAGE . "'");
if (!$db->numRows()) {
$db->select("navigation_lang = '" . DEFAULT_LANGUAGE . "'");
}
$menu = "";
while ($db->nextRecord()) {
if ($db->module != "") {
$menu .= $this->item($db->title, $db->application, $db->module);
} else {
$menu .= $this->item($db->title, $db->application);
}
}
return $menu;
}
示例7: Exception
</td>
</tr>
<tr>
<td><input type="submit" name="install" value="<?php
echo _t("Save");
?>
"></td>
</tr>
</table>
</form>
<?php
if (isset($_POST['install'])) {
try {
if (empty($_POST['name'])) {
throw new Exception("missing form");
}
$db = new DB("widgets");
$db->setColPrefix("widget_");
$db->name = $_POST['name'];
$db->module = $_POST['module'];
$db->group = $_POST['group'];
$db->update("widget_id = '" . $db->escape($this->id) . "'");
header("location: " . page("admin", "widgets"));
} catch (Exception $e) {
echo error(_t($e->getMessage()));
}
}
} catch (Exception $e) {
echo error(_t($e->getMessage()));
}
示例8: getForumCategory
/**
* Get all forum categories
* @param int $selected
* @return string
*/
function getForumCategory($selected = "")
{
$data = "";
$db = new DB("forum_categories");
$db->setColPrefix("category_");
$db->setSort("category_sort ASC");
$db->select();
while ($db->nextRecord()) {
if ($db->id == $selected) {
$data .= "<option value='" . $db->id . "' SELECTED>" . $db->title . "</option>";
} else {
$data .= "<option value='" . $db->id . "'>" . $db->title . "</option>";
}
}
return $data;
}
示例9: Exception
try {
if (!$this->addon) {
throw new Exception("missing data");
}
$addon = new Addon($this->addon);
if (!$addon->checkInstall()) {
throw new Exception("addons is not installable");
}
if (isset($_POST['save'])) {
try {
if ($_POST['secure_input'] != $_SESSION['secure_token']) {
throw new Exception("Wrong secured token");
}
$addon->Install();
$db = new DB("addons");
$db->setColPrefix("addon_");
$db->installed = true;
$db->group = $_POST['group'];
$db->update("addon_name = '" . $db->escape($this->addon) . "'");
header("location: " . page("admin", "addons"), true);
} catch (Exception $e) {
echo error(_t($e->getMessage()));
}
}
$db = new DB("addons");
$db->select("addon_name = '" . $db->escape($this->addon) . "'");
$db->nextRecord();
?>
<h4><?php
echo _t("Edit Addon");
?>
示例10: DB
<td width="40px" class="border-bottom"></td>
<td class="border-bottom"><?php
echo _t("Forum name");
?>
</td>
<td width="70px" class="border-bottom border-right"></td>
<td width="66px" class="border-bottom border-right" align="center"><?php
echo _t("Topics");
?>
</td>
</tr>
</thead>
<tbody>
<?php
$forums = new DB("forum_forums");
$forums->setColPrefix("forum_");
$forums->setSort("forum_sort ASC");
$forums->select("forum_group <= " . $acl->group . " AND forum_category = '" . $forum_cat->id . "'");
while ($forums->nextRecord()) {
$db = new DB();
$db->query("SELECT COUNT(topic_id) as topics FROM {PREFIX}forum_topics WHERE topic_forum = '" . $forums->id . "'");
$db->nextRecord();
$topics = $db->topics;
$db = new DB("forum_topics");
$db->join("left", "{PREFIX}forum_posts", "topic_id", "post_topic");
$db->setSort("post_added DESC");
$db->setLimit("1");
$db->select("topic_forum = '" . $forums->id . "'");
if (!$db->numRows()) {
$last_post = "--";
} else {
示例11: Exception
if (empty($_POST['subject'])) {
throw new Exception("Missing subject name");
}
if (empty($_POST['content'])) {
throw new Exception("Missing topic content");
}
$t = new DB("forum_topics");
$t->setColPrefix("topic_");
$t->userid = USER_ID;
$t->subject = $_POST['subject'];
$t->forum = $forum_id;
$t->insert();
$topic_id = $t->getId();
$topic_name = cleanurl($_POST['subject']);
$p = new DB("forum_posts");
$p->setColPrefix("post_");
$p->topic = $topic_id;
$p->user = USER_ID;
$p->content = $_POST['content'];
$p->added = time();
$p->insert();
$post_id = $p->getId();
header("location: " . page("forums", "view-topic", "{$topic_name}-" . $topic_id, "", "", "page=p{$post_id}#post{$post_id}"));
} catch (Exception $e) {
echo error(_t($e->getMessage()));
}
}
echo "<h4>" . _t("Create topic in") . " " . $db->name . "</h4>";
?>
<form method="post">
示例12: _t
echo _t("Created");
?>
</strong>
</td>
<td width="100px" class="border-bottom">
<strong><?php
echo _t("By");
?>
</strong>
</td>
</tr>
</thead>
<tbody>
<?php
$db = new DB("news");
$db->setColPrefix("news_");
$db->setSort("news_added DESC");
$db->select();
while ($db->nextRecord()) {
$user = new Acl($db->userid);
?>
<tr>
<td class="border-bottom">
<a href="<?php
echo page("admin", "news", "edit", "", "", "id=" . $db->id);
?>
"><?php
echo htmlformat($db->subject, false);
?>
</a>
</td>
示例13: newPasskey
/**
* Generate a new passkey
*/
function newPasskey()
{
$passkey = md5(uniqid(true));
$db = new DB("users");
$db->setColPrefix("user_");
$db->passkey = $passkey;
$db->update("user_id = '" . $this->id . "'");
$this->__set("passkey", $passkey);
}
示例14: Exception
if (!intval($_GET['torrent'])) {
throw new Exception("Invalid id");
}
$torrent_id = $_GET['torrent'];
$torrent = new DB("torrents");
$torrent->setColPrefix("torrent_");
$torrent->select("torrent_id = '" . $torrent_id . "'");
if (!$torrent->numRows()) {
throw new Exception("File not found");
}
$torrent->nextRecord();
if (!isset($_GET['passkey'])) {
$acl = new Acl(USER_ID);
} else {
$db = new DB("users");
$db->setColPrefix("user_");
$db->select("user_passkey = '" . $db->escape($_GET['passkey']) . "'");
if (!$db->numRows()) {
throw new Exception("user not found");
}
$db->nextRecord();
$acl = new Acl($db->id);
}
$fn = PATH_TORRENTS . $torrent->id . ".torrent";
$dict = Bcode::bdec_file($fn, filesize($fn));
$dict['value']['announce']['value'] = CMS_URL . "announce.php?passkey=" . $acl->passkey;
$dict['value']['announce']['string'] = strlen($dict['value']['announce']['value']) . ":" . $dict['value']['announce']['value'];
$dict['value']['announce']['strlen'] = strlen($dict['value']['announce']['string']);
header('Content-Disposition: attachment; filename="' . $torrent->filename . '"');
header("Content-Type: application/x-bittorrent");
die(Bcode::benc($dict));
示例15: SimpleXMLElement
$xml = new SimpleXMLElement("<rss></rss>");
$xml->addAttribute("version", "0.91");
$channel = $xml->addChild("channel");
$channel->addChild("title", $pref->name);
$channel->addChild("link", CMS_URL);
$channel->addChild("description", "");
$channel->addChild("language", "en-usde");
$channel->addChild("copyright", "");
$icon = $channel->addChild("image");
$icon->addChild("title", $pref->name);
$icon->addChild("url", CMS_URL . "favicon.ico");
$icon->addChild("link", CMS_URL);
$icon->addChild("width", "16");
$icon->addChild("height", "16");
$icon->addChild("description", "");
$db = new DB("torrents");
$db->setColPrefix("torrent_");
$db->query("SELECT * FROM {PREFIX}torrents WHERE " . implode(" OR ", $where) . " ORDER BY {$order} LIMIT 15");
while ($db->nextRecord()) {
$link = $feed == "dl" ? page("torrent", "download", "", "", "", "torrent=" . $db->id . "&passkey=" . $passkey) : page("torrent", "details", "", "", "", "torrent=" . $db->id);
$link = htmlentities($link);
$item = $channel->addChild("item");
$item->addChild("title", $db->name);
$item->addChild("link", $link);
$item->addChild("description", $db->nfo);
}
header("Content-Type: application/xml");
die($xml->asXML());
} catch (Exception $e) {
echo $e->getMessage();
}