本文整理汇总了PHP中GDO::table方法的典型用法代码示例。如果您正苦于以下问题:PHP GDO::table方法的具体用法?PHP GDO::table怎么用?PHP GDO::table使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GDO
的用法示例。
在下文中一共展示了GDO::table方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: templateComments
public function templateComments(Module_Comments $mod_c, GWF_News $news, GWF_Comments $comments)
{
$ipp = 10;
$cid = $comments->getID();
$nItems = $comments->getVar('cmts_count');
$nPages = GWF_PageMenu::getPagecount($ipp, $nItems);
$page = Common::clamp(Common::getGetInt('cpage'), 1, $nPages);
$from = GWF_PageMenu::getFrom($page, $ipp);
// Method
$me = $mod_c->getMethod('Reply');
$me instanceof Comments_Reply;
$where = "cmt_cid={$cid}";
$with_perms = !GWF_User::isInGroupS('moderator');
if ($with_perms) {
$visible = GWF_Comment::VISIBLE;
$deleted = GWF_Comment::DELETED;
$flags = $visible | $deleted;
$where .= " cmt_options & {$flags} = {$visible}";
}
$c = GDO::table('GWF_Comment')->selectObjects('*', 'cmt_cid=' . $comments->getID(), 'cmt_date ASC', $ipp, $from);
$href = GWF_WEB_ROOT . 'news-comments-' . $news->getID() . '-' . $news->displayTitle() . '-page-' . $page . '.html';
$hrefp = GWF_WEB_ROOT . 'news-comments-' . $news->getID() . '-' . $news->displayTitle() . '-page-%PAGE%.html';
$tVars = array('news' => $news, 'newsitem' => Module_News::displayBoxB(array($news)), 'pagemenu' => GWF_PageMenu::display($page, $nPages, $hrefp), 'comments' => $comments->displayComments($c, $href), 'form' => $me->templateReply($href));
return $this->module->template('comments.tpl', $tVars);
}
示例2: Upgrade_Slaytags_1_01
function Upgrade_Slaytags_1_01(Module_Slaytags $module)
{
GWF_Website::addDefaultOutput(GWF_HTML::message('Slaytags', "BPM and Key"));
$songs = GDO::table('Slay_Song');
$songs->createColumn('ss_bpm');
$songs->createColumn('ss_key');
}
示例3: templateUsers
private function templateUsers($term = '')
{
$ipp = $this->module->cfgIPP();
$form = $this->getFormQuick();
$usertable = GDO::table('GWF_User');
$by = Common::getGet('by', '');
$dir = Common::getGet('dir', '');
$orderby = $usertable->getMultiOrderby($by, $dir);
if ($term === '') {
$users = array();
$page = 1;
$nPages = 0;
} else {
$eterm = GDO::escape($term);
$deleted = GWF_User::DELETED;
$conditions = "user_name LIKE '%{$eterm}%' AND user_options&{$deleted}=0";
$nItems = $usertable->countRows($conditions);
$nPages = GWF_PageMenu::getPagecount($ipp, $nItems);
$page = Common::clamp(intval(Common::getGet('page', 1)), 1, $nPages);
$from = GWF_PageMenu::getFrom($page, $ipp);
$users = $usertable->selectObjects('*', $conditions, $orderby, $ipp, $from);
}
$href_pagemenu = GWF_WEB_ROOT . 'index.php?mo=Usergroups&me=Search&term=' . urlencode($term) . '&by=' . urlencode($by) . '&dir=' . urlencode($dir) . '&page=%PAGE%';
$tVars = array('form' => $form->templateX(false, false), 'users' => $users, 'sort_url' => GWF_WEB_ROOT . 'index.php?mo=Usergroups&me=Search&term=' . urlencode($term) . '&by=%BY%&dir=%DIR%&page=1', 'page_menu' => GWF_PageMenu::display($page, $nPages, $href_pagemenu), 'href_adv' => $this->module->getMethodURL('SearchAdv'));
return $this->module->templatePHP('search.php', $tVars);
}
示例4: createForums
private static function createForums(Module_WeChall $module, $dropTable)
{
$back = '';
// if (false === ($module_forum = GWF_Module::getModule('Forum'))) {
// return GWF_HTML::err('ERR_MODULE_MISSING', 'Forum');
// }
// $module_forum->onInclude();
$boards = GDO::table('GWF_ForumBoard');
$t = $boards->escape(Module_WeChall::BOARD_CHALLS);
if (false === ($board = $boards->getBy('board_title', $t))) {
if (false === ($board = GWF_ForumBoard::createBoard(Module_WeChall::BOARD_CHALLS, Module_WeChall::BOARD_CHALLS_DESCR, 1, GWF_ForumBoard::GUEST_VIEW | GWF_ForumBoard::ALLOW_THREADS, 0))) {
$back .= GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
}
}
$boardid = $board === false ? 0 : $board->getID();
$module->saveModuleVar('wc_chall_board', $boardid);
$t = $boards->escape(Module_WeChall::BOARD_SOLUTIONS);
if (false === ($board = $boards->getBy('board_title', $t))) {
if (false === ($board = GWF_ForumBoard::createBoard(Module_WeChall::BOARD_SOLUTIONS, Module_WeChall::BOARD_SOLUTIONS_DESCR, 1, GWF_ForumBoard::GUEST_VIEW | GWF_ForumBoard::ALLOW_THREADS, 0))) {
$back .= GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
}
}
$boardid = $board === false ? 0 : $board->getID();
$module->saveModuleVar('wc_sol_board', $boardid);
$t = $boards->escape(Module_WeChall::BOARD_SITES);
if (false === ($board = $boards->getBy('board_title', $t))) {
if (false === ($board = GWF_ForumBoard::createBoard(Module_WeChall::BOARD_SITES, Module_WeChall::BOARD_SITES_DESCR, 1, GWF_ForumBoard::GUEST_VIEW | GWF_ForumBoard::ALLOW_THREADS, 0))) {
$back .= GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
}
}
$boardid = $board === false ? 0 : $board->getID();
$module->saveModuleVar('wc_site_board', $boardid);
return $back;
}
示例5: selectUsers
/**
* Select Users For Global Ranking.
* @param int $count
* @param int $from
* @return array
*/
private function selectUsers($count, $from)
{
$db = gdo_db();
$count = (int) $count;
$from = (int) $from;
$regat = GDO::table('WC_RegAt')->getTableName();
$users = GDO::table('GWF_User')->getTableName();
$query = "SELECT user_id,user_name,user_level,SUM(regat_score) AS lts, COUNT(regat_score) AS nlinks, regat_langid,user_countryid FROM {$regat} AS B JOIN (SELECT user_id,user_name,user_level,user_countryid FROM {$users} WHERE user_options&0x10000000=0 ORDER BY user_level DESC, user_id ASC LIMIT {$from}, {$count}) AS C ON user_id=regat_uid GROUP by user_id,regat_langid ORDER BY user_level DESC, user_id ASC";
$back = array();
if (false === ($result = $db->queryRead($query))) {
return $back;
}
$current = false;
while (false !== ($row = $db->fetchAssoc($result))) {
if ($current === false) {
$current = new GWF_User($row);
$current->setVar('nlinks', 0);
$back[] = $current;
} elseif ($current->getVar('user_id') !== $row['user_id']) {
if (count($back) === $count) {
break;
}
$current = new GWF_User($row);
$current->setVar('nlinks', 0);
$back[] = $current;
}
$current->setVar('grank_' . $row['regat_langid'], $row['lts']);
$current->setVar('nlinks', $current->getVar('nlinks') + $row['nlinks']);
// var_dump($current->getGDOData());
}
$db->free($result);
// var_dump($back);
return $back;
}
示例6: getNavigation
/** @return array|false */
private function getNavigation($id)
{
if (false === ($navis = GWF_Navigations::getById($id))) {
return false;
# TODO
}
$nsid = $navis->getID();
$pb = $navis->isnotPB() ? 'navi_vars' : 'navi_pbvars';
$cols = 't.*, page_url, page_title, page_lang, page_meta_desc/*, page_views,*/';
$t = GDO::table('GWF_Navigation');
# TODO: page_lang, permissions
$where = "navi_nid={$nsid}";
$navi = array();
$navi['category_name'] = $navis->getName();
$navi['subs'] = array();
$navi['links'] = false !== ($links = $t->selectAll($cols, $where, 'navi_position', array($pb))) ? $links : array();
if (false === ($subs = $navis->selectAll('navis_id', 'navis_pid=' . $nsid))) {
$subs = array();
# TODO: error
}
foreach ($subs as $sub) {
if (false !== ($sn = $this->getNavigation($sub['navis_id']))) {
$navi['subs'][] = $sn;
} else {
# TODO
}
}
return $navi;
}
示例7: onSearch
public function onSearch()
{
$form = $this->getForm();
// if (false !== ($error = $form->validate($this->module))) {
// return $error.$this->templateSearch();
// }
$users = GDO::table('GWF_User');
$term = Common::getRequest('term');
if (false !== ($error = $this->validate_term($this->module, $term))) {
return $error;
}
$fields = array('user_name', 'user_email');
$by = Common::getGet('by', self::DEFAULT_BY);
$dir = Common::getGet('dir', self::DEFAULT_DIR);
$orderby = $users->getMultiOrderby($by, $dir);
if (false === ($conditions = GWF_QuickSearch::getQuickSearchConditions($users, $fields, $term))) {
$conditions = '0';
}
$hits = $users->countRows($conditions);
$ipp = $this->module->cfgUsersPerPage();
$nPages = GWF_PageMenu::getPagecount($ipp, $hits);
$page = Common::clamp((int) Common::getGet('page', 1), 1, $nPages);
$from = GWF_PageMenu::getFrom($page, $ipp);
$tVars = array('searched' => true, 'form' => $form->templateX($this->module->lang('ft_search')), 'hits' => $hits, 'users' => $users->selectObjects('*', $conditions, $orderby, $ipp, $from), 'term' => $term, 'pagemenu' => GWF_PageMenu::display($page, $nPages, GWF_WEB_ROOT . 'index.php?mo=Admin&me=UserSearch&term=' . urlencode($term) . '&by=' . urlencode($by) . '&dir=' . urlencode($dir) . '&page=1'), 'sort_url' => GWF_WEB_ROOT . 'index.php?mo=Admin&me=UserSearch&term=' . urlencode($term) . '&by=%BY%&dir=%DIR%&page=1');
return $this->module->templatePHP('user_search.php', $tVars);
}
示例8: templateSongs
private function templateSongs()
{
// $user = GWF_Session::getUser();
// $uid = $user->getID();
$table = GDO::table('Slay_Song');
$joins = NULL;
$headers = array();
$headers[] = array($this->module->lang('th_artist'), 'ss_artist');
$headers[] = array($this->module->lang('th_title'), 'ss_title');
$headers[] = array($this->module->lang('th_duration'), 'ss_duration');
$headers[] = array($this->module->lang('th_bpm'), 'ss_bpm');
$headers[] = array($this->module->lang('th_key'), 'ss_key');
$headers[] = array($this->module->lang('D'));
$headers[] = array($this->module->lang('L'));
$headers[] = array($this->module->lang('T'));
$headers[] = array($this->module->lang('th_tags'));
$where = "";
$nItems = $table->selectVar('COUNT(ss_id)', $where, '', $joins);
$nPages = GWF_PageMenu::getPagecount(self::IPP, $nItems);
$page = Common::clamp(Common::getGetInt('page'), 1, $nPages);
$by = Common::getGetString('by', self::BY);
$dir = Common::getGetString('dir', self::DIR);
$orderby = $table->getMultiOrderby($by, $dir, false);
$songs = $table->selectAll('*', $where, $orderby, $joins, self::IPP, GWF_PageMenu::getFrom($page, self::IPP), GDO::ARRAY_O);
$tVars = array('is_dj' => GWF_User::isInGroupS('dj'), 'sort_url' => GWF_WEB_ROOT . 'index.php?mo=Slaytags&me=Songs&by=%BY%&dir=%DIR%&page=1', 'pagemenu' => GWF_PageMenu::display($page, $nPages, GWF_WEB_ROOT . sprintf('index.php?mo=Slaytags&me=Songs&by=%s&dir=%s&page=%%PAGE%%', urlencode($by), urlencode($dir))), 'songs' => $songs, 'headers' => $headers);
return $this->module->template('songs.tpl', $tVars);
}
示例9: onCleanupUntagged
private function onCleanupUntagged()
{
$songs = GDO::table('Slay_Song');
$cut = GWF_Time::getDate(14, time() - 3600);
$songs->deleteWhere("ss_taggers=0 AND ss_last_played<'{$cut}'");
return $this->module->message('msg_cleanup');
}
示例10: templateChalls
public function templateChalls($for_userid = false, $from_userid = false, $tag = '', $by = '', $dir = '', $show_cloud = true, $show_empty = true)
{
require_once GWF_CORE_PATH . 'module/WeChall/WC_ChallSolved.php';
$challs = GDO::table('WC_Challenge');
$for_userid = (int) $for_userid;
$from_userid = (int) $from_userid;
$solved_bits = $for_userid > 0 ? WC_ChallSolved::getSolvedForUser($for_userid, true) : array();
if (count($solved_bits) === 0 && !$show_empty && $from_userid === 0) {
return '';
}
$solve_filter = Common::getGetString('filter', '');
if ($solve_filter === 'solved' or $solve_filter == 'open') {
$filter_prefix = $solve_filter . '_';
} else {
$filter_prefix = '';
}
$from_query = $from_userid === 0 ? '1' : "chall_creator LIKE '%,{$from_userid},%'";
$conditions = "({$from_query})";
if (0 === ($count = $challs->countRows($conditions))) {
return '';
}
$orderby = $challs->getMultiOrderby($by, $dir);
$tag_2 = $tag == '' ? '' : $tag . '/';
$this->setPageDescr($for_userid, $from_userid, $tag, $count);
$sort_url = 'challs/' . $tag_2 . 'by/' . $by . '/' . $dir . '/page-1';
$tVars = array('filter_prefix' => $filter_prefix, 'sort_url' => GWF_WEB_ROOT . $filter_prefix . 'challs/' . $tag_2 . 'by/%BY%/%DIR%/page-1', 'challs' => $challs->selectObjects('*', $conditions, $orderby), 'tags' => $show_cloud ? $this->getTags() : '', 'solved_bits' => $solved_bits, 'table_title' => $this->getTableTitle($for_userid, $from_userid, $tag, $count), 'tag' => $tag, 'by' => $by, 'dir' => $dir, 'href_all' => GWF_WEB_ROOT . $sort_url, 'href_solved' => GWF_WEB_ROOT . 'solved_' . $sort_url, 'href_unsolved' => GWF_WEB_ROOT . 'open_' . $sort_url, 'sel_all' => $solve_filter === '', 'sel_solved' => $solve_filter === 'solved', 'sel_unsolved' => $solve_filter === 'open');
return $this->module->templatePHP('challs.php', $tVars);
}
示例11: templateSites
private function templateSites()
{
require_once GWF_CORE_PATH . 'module/WeChall/WC_SiteAdmin.php';
require_once GWF_CORE_PATH . 'module/WeChall/WC_SiteCats.php';
require_once GWF_CORE_PATH . 'module/WeChall/WC_SiteDescr.php';
$tag = Common::getGet('tag', '');
if (0 === ($tag_bit = WC_SiteCats::getBitForCat($tag))) {
$tag = '';
}
$this->setPageDescription($tag);
$status_query = $this->getStatusQuery();
$lang_query = $this->getLangQuery();
$tag_query = $this->getTagQuery($tag_bit);
$ipp = $this->module->cfgItemsPerPage();
$by = Common::getGet('by', 'site_id');
$dir = Common::getGet('dir', 'DESC');
$page = intval(Common::getGet('page', 1));
$table = GDO::table('WC_Site');
$orderby = $table->getMultiOrderby($by, $dir);
$conditions = "({$status_query}) AND ({$lang_query}) AND ({$tag_query})";
$nItems = $table->countRows($conditions);
$nPages = GWF_PageMenu::getPagecount($ipp, $nItems);
$page = Common::clamp($page, 1, $nPages);
$href = $this->getPageMenuHREF();
$tVars = array('sites' => $table->selectObjects('*', $conditions, $orderby, $ipp, GWF_PageMenu::getFrom($page, $ipp)), 'descrs' => WC_SiteDescr::getAllDescr(), 'site_quickjump' => $this->module->templateSiteQuickjumpDetail(), 'pagemenu' => GWF_PageMenu::display($page, $nPages, $href), 'sortURL' => $this->getTableSortURL(), 'which' => intval(Common::getGet('which')), 'tag' => $tag, 'page_title' => $this->pageTitle);
return $this->module->templatePHP('sites.php', $tVars);
}
示例12: core
public static function core($drop = false, &$success)
{
$db = gdo_db();
$tables = self::get_core_tables();
$success = true;
$ret = '<br/><br/>';
foreach ($tables as $classname) {
$ret .= sprintf("Installing %s table ... ", $classname);
if (false === ($result = GDO::table($classname)->createTable($drop))) {
#error
$ret .= '<b class="gwfinstallno">FAILED!<br/>' . PHP_EOL;
$success = false;
} else {
#success
$ret .= '<b class="gwfinstallyes">OK</b><br/>' . PHP_EOL;
}
}
$ret .= '<br/>';
/** Try to set a birthdate **/
if (false === GWF_Settings::getSetting('gwf_site_birthday', false)) {
$ret .= sprintf("Setting up a birthdate ... %s.", date('Ymd'));
if (false === GWF_Settings::setSetting('gwf_site_birthday', date('Ymd'))) {
$ret .= '<b class="gwfinstallno">Cannot set site birthdate.<br/>' . PHP_EOL;
$success = false;
}
}
return $ret;
}
示例13: getDescription
public static function getDescription($siteid)
{
$siteid = (int) $siteid;
$browser_lid = GWF_Language::getCurrentID();
if (false === ($result = GDO::table('WC_Site')->selectAll('site_desc_lid, site_desc_txt', "site_desc_sid={$siteid} AND (site_desc_lid= {$browser_lid} OR site_desc_lid=site_descr_lid)", '', array('description'), 2, 0, GDO::ARRAY_N))) {
return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
}
// $sites = GWF_TABLE_PREFIX.'wc_site';
// $descr = GWF_TABLE_PREFIX.'wc_site_descr';
// $db = gdo_db();
//
// $query = "SELECT site_desc_lid, site_desc_txt FROM $sites JOIN $descr ON site_desc_sid=site_id WHERE site_desc_sid=$siteid AND (site_desc_lid=$browser_lid OR site_desc_lid=site_descr_lid)";
//
// if (false === ($result = $db->queryAll($query, false))) {
// return '';
// }
//
if (count($result) === 2) {
if ($result[0][0] === $browser_lid) {
return $result[0][1];
} else {
return $result[1][1];
}
} else {
return $result[0][1];
}
}
示例14: onDeleteFolder
public function onDeleteFolder($folderid)
{
# Permission
$folderid = (int) $folderid;
$user = GWF_Session::getUser();
if (false === ($folder = GWF_PMFolder::getByID($folderid)) || $folder->getVar('pmf_uid') !== $user->getID()) {
return $this->module->error('err_folder_perm');
}
# Delete PMs$result
$count = 0;
$pms = GDO::table('GWF_PM');
$uid = $user->getVar('user_id');
$fid = "{$folderid}";
$del = GWF_PM::OWNER_DELETED;
if (false === ($result = $pms->update("pm_options=pm_options|{$del}", "pm_owner={$uid} AND pm_folder={$fid}"))) {
return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
}
$count += $pms->affectedRows($result);
// $del = GWF_PM::FROM_DELETED;
// if (false === $pms->update("pm_options=pm_options|$del", "pm_from=$uid AND pm_from_folder=$fid")) {
// return GWF_HTML::err('ERR_DATABASE', array( __FILE__, __LINE__));
// }
// $count += $pms->affectedRows();
if ($folderid > 2) {
# Delete Folder
if (false === $folder->delete()) {
return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
}
}
# Done
return $this->module->message('msg_folder_deleted', array($folder->display('pmf_name'), $count));
}
示例15: getWarboxes
private function getWarboxes($all = false)
{
$table = GDO::table('WC_Warbox');
$joins = array('sites');
$orderby = 'site_name ASC, wb_name ASC';
if (!$all) {
$where = 'site_status IN ("up","down")';
} else {
$where = '';
}
return $table->selectAll('*', $where, $orderby, $joins, -1, -1, GDO::ARRAY_O);
// $table = GDO::table('WC_Site');
// $back = array();
// $where = 'site_options&'.WC_Site::IS_WARBOX;
// $where .= $all ? '' : ' AND site_status IN ("up","down")';
// if (false === ($result = $table->selectColumn('site_id', $where)))
// {
// return $back;
// }
// foreach ($result as $siteid)
// {
// if (false !== ($site = WC_Site::getByID_Class($siteid)))
// {
// $back[] = $site;
// }
// }
// return $back;
}