本文整理汇总了PHP中qa_db_read_all_assoc函数的典型用法代码示例。如果您正苦于以下问题:PHP qa_db_read_all_assoc函数的具体用法?PHP qa_db_read_all_assoc怎么用?PHP qa_db_read_all_assoc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qa_db_read_all_assoc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: output_widget
function output_widget($region, $place, $themeobject, $template, $request, $qa_content)
{
if (!qa_opt('event_logger_to_database')) {
return;
}
$badges = qa_db_read_all_assoc(qa_db_query_sub('SELECT event,handle,params, UNIX_TIMESTAMP(datetime) AS datetime FROM ^eventlog WHERE event=$' . (qa_opt('badge_widget_date_max') ? ' AND DATE_SUB(CURDATE(),INTERVAL ' . (int) qa_opt('badge_widget_date_max') . ' DAY) <= datetime' : '') . ' ORDER BY datetime DESC' . (qa_opt('badge_widget_list_max') ? ' LIMIT ' . (int) qa_opt('badge_widget_list_max') : ''), 'badge_awarded'));
if (empty($badges)) {
return;
}
$themeobject->output('<h2>' . qa_lang('badges/badge_widget_title') . '</h2>');
foreach ($badges as $badge) {
$params = array();
$paramsa = explode("\t", $badge['params']);
foreach ($paramsa as $param) {
$parama = explode('=', $param);
$params[$parama[0]] = $parama[1];
}
$slug = $params['badge_slug'];
$typea = qa_get_badge_type_by_slug($slug);
$types = $typea['slug'];
$typed = $typea['name'];
$badge_name = qa_lang('badges/' . $slug);
if (!qa_opt('badge_' . $slug . '_name')) {
qa_opt('badge_' . $slug . '_name', $badge_name);
}
$var = qa_opt('badge_' . $slug . '_var');
$name = qa_opt('badge_' . $slug . '_name');
$desc = qa_badge_desc_replace($slug, $var, $name);
$string = '<span class="badge-' . $types . '" title="' . $desc . ' (' . $typed . ')">' . qa_html($name) . '<br/>- ' . $badge['handle'] . ' -</span>';
$themeobject->output('<div class="badge-widget-entry" style="padding-top:8px;">', $string, '</div>');
}
}
示例2: q_list
public function q_list($q_list)
{
if (!empty($q_list['qs']) && qa_opt('mouseover_content_on')) {
// first check it is not an empty list and the feature is turned on
// Collect the question ids of all items in the question list (so we can do this in one DB query)
$postids = array();
foreach ($q_list['qs'] as $question) {
if (isset($question['raw']['postid'])) {
$postids[] = $question['raw']['postid'];
}
}
if (!empty($postids)) {
// Retrieve the content for these questions from the database and put into an array fetching
// the minimal amount of characters needed to determine the string should be shortened or not
$maxlength = qa_opt('mouseover_content_max_len');
$result = qa_db_query_sub('SELECT postid, LEFT(content, #) content, format FROM ^posts WHERE postid IN (#)', $maxlength + 1, $postids);
$postinfo = qa_db_read_all_assoc($result, 'postid');
// Get the regular expression fragment to use for blocked words and the maximum length of content to show
$blockwordspreg = qa_get_block_words_preg();
// Now add the popup to the title for each question
foreach ($q_list['qs'] as $index => $question) {
if (isset($postinfo[$question['raw']['postid']])) {
$thispost = $postinfo[$question['raw']['postid']];
$text = qa_viewer_text($thispost['content'], $thispost['format'], array('blockwordspreg' => $blockwordspreg));
$text = qa_shorten_string_line($text, $maxlength);
$title = isset($question['title']) ? $question['title'] : '';
$q_list['qs'][$index]['title'] = sprintf('<span title="%s">%s</span>', qa_html($text), $title);
}
}
}
}
qa_html_theme_base::q_list($q_list);
// call back through to the default function
}
示例3: q_list
public function q_list($q_list)
{
if (!empty($q_list['qs']) && qa_opt('mouseover_content_on')) {
// first check it is not an empty list and the feature is turned on
// Collect the question ids of all items in the question list (so we can do this in one DB query)
$postids = array();
foreach ($q_list['qs'] as $question) {
if (isset($question['raw']['postid'])) {
$postids[] = $question['raw']['postid'];
}
}
if (!empty($postids)) {
// Retrieve the content for these questions from the database
$maxlength = qa_opt('mouseover_content_max_len');
$result = qa_db_query_sub('SELECT postid, content, format FROM ^posts WHERE postid IN (#)', $postids);
$postinfo = qa_db_read_all_assoc($result, 'postid');
// Get the regular expression fragment to use for blocked words and the maximum length of content to show
$blockwordspreg = qa_get_block_words_preg();
// Now add the popup to the title for each question
foreach ($q_list['qs'] as $index => $question) {
if (isset($postinfo[$question['raw']['postid']])) {
$thispost = $postinfo[$question['raw']['postid']];
$text = qa_viewer_text($thispost['content'], $thispost['format'], array('blockwordspreg' => $blockwordspreg));
$text = preg_replace('/\\s+/', ' ', $text);
// Remove duplicated blanks, new line characters, tabs, etc
$text = qa_shorten_string_line($text, $maxlength);
$title = isset($question['title']) ? $question['title'] : '';
$q_list['qs'][$index]['title'] = $this->getHtmlTitle(qa_html($text), $title);
}
}
}
}
parent::q_list($q_list);
// call back through to the default function
}
示例4: q_list
function q_list($q_list)
{
if (count(@$q_list['qs']) && qa_opt('mouseover_content_on')) {
// first check it is not an empty list and the feature is turned on
// Collect the question ids of all items in the question list (so we can do this in one DB query)
$postids = array();
foreach ($q_list['qs'] as $question) {
if (isset($question['raw']['postid'])) {
$postids[] = $question['raw']['postid'];
}
}
if (count($postids)) {
// Retrieve the content for these questions from the database and put into an array
$result = qa_db_query_sub('SELECT postid, content, format FROM ^posts WHERE postid IN (#)', $postids);
$postinfo = qa_db_read_all_assoc($result, 'postid');
// Get the regular expression fragment to use for blocked words and the maximum length of content to show
$blockwordspreg = qa_get_block_words_preg();
$maxlength = qa_opt('mouseover_content_max_len');
// Now add the popup to the title for each question
foreach ($q_list['qs'] as $index => $question) {
$thispost = @$postinfo[$question['raw']['postid']];
if (isset($thispost)) {
$text = qa_viewer_text($thispost['content'], $thispost['format'], array('blockwordspreg' => $blockwordspreg));
$text = qa_shorten_string_line($text, $maxlength);
$q_list['qs'][$index]['title'] = '<SPAN TITLE="' . qa_html($text) . '">' . @$question['title'] . '</SPAN>';
}
}
}
}
qa_html_theme_base::q_list($q_list);
// call back through to the default function
}
示例5: q2apro_save_most_viewed_questions
function q2apro_save_most_viewed_questions()
{
// save checktime of cache
qa_opt('q2apro_popularqu_checktime', time());
$maxquestions = qa_opt('q2apro_popularqu_maxqu');
$lastdays = qa_opt('q2apro_popularqu_lastdays');
$ourTopQuestions = qa_db_read_all_assoc(qa_db_query_sub('SELECT postid, title, acount FROM `^posts`
WHERE `created` > NOW() - INTERVAL # DAY
AND `type` = "Q"
AND `closedbyid` IS NULL
ORDER BY views DESC
LIMIT #;', $lastdays, $maxquestions));
$saveoutput = '';
foreach ($ourTopQuestions as $qu) {
$activity_url = qa_path_html(qa_q_request($qu['postid'], $qu['title']), null, qa_opt('site_url'), null, null);
$questionlink = '<a href="' . $activity_url . '">' . htmlspecialchars($qu['title']) . '</a>';
$answercnt = '';
if (qa_opt('q2apro_popularqu_answercount')) {
$acnttitle = $qu['acount'] == 1 ? qa_lang('q2apro_popularqu_lang/answer_one') : $qu['acount'] . ' ' . qa_lang('q2apro_popularqu_lang/answers');
$answercnt = ' <span title="' . $acnttitle . '">(' . $qu['acount'] . ')</span>';
}
$saveoutput .= '<li>
' . $questionlink . $answercnt . '
</li>
';
}
// save into cache
qa_opt('q2apro_popularqu_cached', $saveoutput);
}
示例6: cs_events
function cs_events($limit = 10, $events_type = false)
{
if (!$events_type) {
$events_type = array('q_post', 'a_post', 'c_post', 'a_select', 'badge_awarded');
}
// query last 3 events
$posts = qa_db_read_all_assoc(qa_db_query_sub('SELECT datetime,ipaddress,handle,event,params FROM ^eventlog WHERE event IN ("q_post", "a_post", "c_post") ORDER BY datetime DESC LIMIT #', $limit));
if (empty($posts)) {
return;
}
$postids = '';
$i = 1;
foreach ($posts as $post) {
$params = preg_replace('/\\s+/', '&', $post['params']);
parse_str($params, $data);
$postids .= ($i != 1 ? ', ' : '') . $data['postid'];
$i++;
}
$posts = qa_db_read_all_assoc(qa_db_query_sub('SELECT ^posts.* , ^users.handle FROM ^posts, ^users WHERE (^posts.userid=^users.userid AND ^posts.postid IN (' . $postids . ')) AND ^posts.type IN ("Q", "A", "C") ORDER BY ^posts.created DESC'));
$o = '<ul class="ra-activity">';
foreach ($posts as $p) {
$event_name = '';
$event_icon = '';
if ($p['type'] == 'Q') {
$event_name = qa_lang('cleanstrap/asked');
$event_icon = 'icon-question';
} else {
if ($p['type'] == 'A') {
$event_name = qa_lang('cleanstrap/answered');
$event_icon = 'icon-answer';
} else {
$event_name = qa_lang('cleanstrap/commented');
$event_icon = 'icon-chat';
}
}
$username = is_null($p['handle']) ? qa_lang('cleanstrap/anonymous') : htmlspecialchars($p['handle']);
$usernameLink = is_null($p['handle']) ? qa_lang('cleanstrap/anonymous') : '<a href="' . qa_path_html('user/' . $p['handle']) . '">' . $p['handle'] . '</a>';
$timeCode = qa_when_to_html(strtotime($p['created']), 7);
$time = @$timeCode['prefix'] . @$timeCode['data'] . @$timeCode['suffix'];
$o .= '<li class="event-item">';
$o .= '<div class="event-inner">';
$o .= '<div class="event-icon pull-left ' . $event_icon . '"></div>';
$o .= '<div class="event-content">';
$o .= '<p class="title"><strong class="avatar" data-handle="' . $p['handle'] . '" data-id="' . $p['userid'] . '">' . @$usernameLink . '</strong> <span class="what">' . $event_name . '</span></p>';
if ($p['type'] == 'Q') {
$o .= '<a class="event-title" href="' . qa_q_path_html($p['postid'], $p['title']) . '" title="' . $p['title'] . '">' . cs_truncate($p['title'], 100) . '</a>';
} elseif ($p['type'] == 'A') {
$o .= '<a class="event-title" href="' . cs_post_link($p['parentid']) . '#a' . $p['postid'] . '">' . cs_truncate(strip_tags($p['content']), 100) . '</a>';
} else {
$o .= '<a class="event-title" href="' . cs_post_link($p['parentid']) . '#c' . $p['postid'] . '">' . cs_truncate(strip_tags($p['content']), 100) . '</a>';
}
$o .= '<span class="time">' . $time . '</span>';
$o .= '</div>';
$o .= '</div>';
$o .= '</li>';
}
$o .= '</ul>';
return $o;
}
示例7: mp_announcements_get_all
function mp_announcements_get_all($categoryid)
{
/*
Return all annoucement posts
*/
$results = qa_db_read_all_assoc(qa_db_query_sub('select p.*, u.handle from ^posts p, ^users u where p.type="AN" AND p.categoryid=# AND p.userid = u.userid ORDER BY p.created DESC', $categoryid), 'postid');
return $results;
}
示例8: qa_db_uservoteflag_posts_get
function qa_db_uservoteflag_posts_get($postids)
{
if (QA_FINAL_EXTERNAL_USERS) {
return qa_db_read_all_assoc(qa_db_query_sub('SELECT postid, userid, vote, flag FROM ^uservotes WHERE postid IN (#) AND ((vote!=0) OR (flag!=0))', $postids));
} else {
return qa_db_read_all_assoc(qa_db_query_sub('SELECT postid, handle, vote, flag FROM ^uservotes LEFT JOIN ^users ON ^uservotes.userid=^users.userid WHERE postid IN (#) AND ((vote!=0) OR (flag!=0))', $postids));
}
}
示例9: get_widgets_by_position
function get_widgets_by_position($position)
{
$widgets = qa_db_read_all_assoc(qa_db_query_sub('SELECT * FROM ^cs_widgets WHERE position = $ ORDER BY widget_order', $position));
foreach ($widgets as $k => $w) {
$param = unserialize($w['param']);
$widgets[$k]['param'] = $param;
}
return $widgets;
}
示例10: qa_get_public_from_userids
function qa_get_public_from_userids($userids)
{
global $table_prefix;
if (count($userids)) {
return qa_db_read_all_assoc(qa_db_query_sub('SELECT user_nicename, ID FROM ' . $table_prefix . 'users WHERE ID IN (#)', $userids), 'ID', 'user_nicename');
} else {
return array();
}
}
示例11: cs_user_post_list
function cs_user_post_list($handle, $type, $limit)
{
$userid = qa_handle_to_userid($handle);
require_once QA_INCLUDE_DIR . 'qa-app-posts.php';
$post = qa_db_read_all_assoc(qa_db_query_sub('SELECT * FROM ^posts INNER JOIN ^users ON ^posts.userid=^users.userid WHERE ^posts.type=$ and ^posts.userid=# ORDER BY ^posts.created DESC LIMIT #', $type, $userid, $limit));
$output = '<ul class="question-list users-post-widget post-type-' . $type . '">';
if (count($post) > 0) {
foreach ($post as $p) {
if ($type == 'Q') {
$what = qa_lang_html('cleanstrap/asked');
} elseif ($type == 'A') {
$what = qa_lang_html('cleanstrap/answered');
} elseif ('C') {
$what = qa_lang_html('cleanstrap/commented');
}
$handle = $p['handle'];
$output .= '<li id="q-list-' . $p['postid'] . '" class="question-item">';
if ($type == 'Q') {
$output .= '<div class="big-ans-count pull-left">' . $p['acount'] . '<span>' . qa_lang_html('cleanstrap/ans') . '</span></div>';
} elseif ($type == 'A') {
$output .= '<div class="big-ans-count pull-left icon-answer"></div>';
} elseif ($type == 'C') {
$output .= '<div class="big-ans-count pull-left icon-comment icon-comments"></div>';
}
$output .= '<div class="list-right">';
$timeCode = qa_when_to_html(strtotime($p['created']), 7);
$when = @$timeCode['prefix'] . @$timeCode['data'] . @$timeCode['suffix'];
if ($type == 'Q') {
$output .= '<h5><a href="' . qa_q_path_html($p['postid'], $p['title']) . '" title="' . $p['title'] . '">' . qa_html($p['title']) . '</a></h5>';
} elseif ($type == 'A') {
$output .= '<h5><a href="' . cs_post_link($p['parentid']) . '#a' . $p['postid'] . '">' . cs_truncate(strip_tags($p['content']), 300) . '</a></h5>';
} else {
$output .= '<h5><a href="' . cs_post_link($p['parentid']) . '#c' . $p['postid'] . '">' . cs_truncate(strip_tags($p['content']), 300) . '</a></h5>';
}
$output .= '<div class="list-date"><span class="icon-clock">' . $when . '</span>';
$output .= '<span class="icon-thumbs-up2">' . qa_lang_sub('cleanstrap/x_votes', $p['netvotes']) . '</span></div>';
$output .= '</div>';
$output .= '</li>';
}
} else {
if ($type == 'Q') {
$what = 'questions';
} elseif ($type == 'A') {
$what = 'answers';
} elseif ('C') {
$what = 'comments';
}
$output .= '<li class="no-post-found">' . qa_lang('cleanstrap/no_' . $what) . ' </li>';
}
$output .= '</ul>';
echo $output;
}
示例12: html
function html()
{
if (qa_post_text('ajax_merge_get_from')) {
$posts = qa_db_read_all_assoc(qa_db_query_sub("SELECT postid,title FROM ^posts WHERE postid IN (#,#)", qa_post_text('ajax_merge_get_from'), qa_post_text('ajax_merge_get_to')));
if ($posts[0]['postid'] == (int) qa_post_text('ajax_merge_get_from')) {
echo '{"from":"' . $posts[0]['title'] . '","to":"' . $posts[1]['title'] . '","from_url":"' . qa_path_html(qa_q_request((int) qa_post_text('ajax_merge_get_from'), $posts[0]['title']), null, qa_opt('site_url')) . '","to_url":"' . qa_path_html(qa_q_request((int) qa_post_text('ajax_merge_get_to'), $posts[1]['title']), null, qa_opt('site_url')) . '"}';
} else {
echo '{"from":"' . $posts[1]['title'] . '","to":"' . $posts[0]['title'] . '","from_url":"' . qa_path_html(qa_q_request((int) qa_post_text('ajax_merge_get_from'), $posts[1]['title']), null, qa_opt('site_url')) . '","to_url":"' . qa_path_html(qa_q_request((int) qa_post_text('ajax_merge_get_to'), $posts[0]['title']), null, qa_opt('site_url')) . '"}';
}
return;
}
qa_html_theme_base::html();
}
示例13: qa_get_public_from_userids
function qa_get_public_from_userids($userids)
{
global $wpdb, $qa_cache_wp_user_emails;
if (count($userids)) {
$useridtopublic = array();
$qa_cache_wp_user_emails = array();
$userfields = qa_db_read_all_assoc(qa_db_query_sub('SELECT ID, user_nicename, user_email FROM ' . $wpdb->base_prefix . 'users WHERE ID IN (#)', $userids), 'ID');
foreach ($userfields as $id => $fields) {
$useridtopublic[$id] = $fields['user_nicename'];
$qa_cache_wp_user_emails[$id] = $fields['user_email'];
}
return $useridtopublic;
} else {
return array();
}
}
示例14: doctype
function doctype()
{
qa_html_theme_base::doctype();
if (qa_opt('cp_enable') && ($this->template == 'ask' || isset($this->content['q_list']) || isset($this->content['q_view']))) {
global $qa_request;
global $wiki_enable;
if ($this->template == 'ask' && !qa_user_permit_error('permit_post_q') && !qa_opt('site_maintenance') && qa_permit_check('permit_create_cp')) {
$this->content['form']['tags'] .= ' onSubmit="pollSubmit(event)"';
$this->content['form']['fields'][] = array('label' => qa_lang('cp/checkbox_text'), 'tags' => 'NAME="cp_community" ID="cp_community"', 'type' => 'checkbox', 'value' => qa_post_text('cp_community') ? 1 : 0);
}
if (isset($this->content['q_view'])) {
$qid = $this->content['q_view']['raw']['postid'];
$author = $this->content['q_view']['raw']['userid'];
if (!isset($wiki_enable)) {
$result = qa_db_query_sub('SELECT * FROM ^postmeta WHERE meta_key=$ AND post_id=#', 'is_community', $qid);
$wiki_enable = $result->num_rows > 0;
}
if ($wiki_enable) {
// is a community post
$this->content['title'] .= ' ' . qa_lang('cp/question_title');
// $this->content['q_view']['content'] = @$this->content['q_view']['content'].'<div id="qa-wiki-div">'.$this->getPollDiv($qid,qa_get_logged_in_userid()).'</div>';
$this->content['q_view']['main_form_tags'] = @$this->content['q_view']['main_form_tags'] . ' class="qa-community-posts"';
// print_r($this->content['q_view']['form']['buttons']);
if (isset($this->content['q_view']['form']['buttons']['edit'])) {
$this->content['q_view']['form']['buttons']['edit']['label'] = qa_lang_html('cp/contribute');
$this->content['q_view']['form']['buttons']['edit']['popup'] = qa_lang_html('cp/contribute_description');
}
unset($this->content['q_view']['form']['buttons']['answer']);
unset($this->content['q_view']['form']['buttons']['comment']);
unset($this->content['a_form']);
unset($this->content['c_form']);
}
}
if (isset($this->content['q_list'])) {
$wiki_array = qa_db_read_all_assoc(qa_db_query_sub('SELECT * FROM ^postmeta WHERE meta_key=$', 'is_community'));
foreach ($wiki_array as $q) {
$wiki[(int) $q['post_id']] = $q['meta_value'];
}
foreach ($this->content['q_list']['qs'] as $idx => $question) {
if (isset($wiki[$question['raw']['postid']])) {
$this->content['q_list']['qs'][$idx]['title'] .= ' ' . qa_lang('cp/question_title');
}
}
}
}
}
示例15: doctype
function doctype()
{
if (qa_opt($this->opt) === '1') {
// fetch all widgets into a basic list
$sql = 'SELECT * FROM ^' . $this->pluginkey . ' ORDER BY ordering';
$widgets = qa_db_read_all_assoc(qa_db_query_sub($sql));
foreach ($widgets as $wid) {
$wid['pages'] = explode(',', @$wid['pages']);
$show_all = $wid['pages'][0] == 'all';
$show_tmpl = in_array($this->template, $wid['pages']);
$show_custom = in_array('custom:' . $this->request, $wid['pages']);
if ($show_all || $show_tmpl || $show_custom) {
$this->widgets[] = $wid;
}
}
}
parent::doctype();
}