当前位置: 首页>>代码示例>>PHP>>正文


PHP qa_db_read_one_assoc函数代码示例

本文整理汇总了PHP中qa_db_read_one_assoc函数的典型用法代码示例。如果您正苦于以下问题:PHP qa_db_read_one_assoc函数的具体用法?PHP qa_db_read_one_assoc怎么用?PHP qa_db_read_one_assoc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了qa_db_read_one_assoc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: AddCategoryToPost

 function AddCategoryToPost($params, $category)
 {
     require_once QA_INCLUDE_DIR . 'qa-db-post-update.php';
     $postid = $params['postid'];
     $result = qa_db_read_one_assoc(qa_db_query_sub('SELECT categoryid,parentid,tags,title,content,qcount,position,backpath FROM ^categories WHERE title=$', $category), true);
     if (empty($result)) {
         //create category
         $tags = str_replace(' ', '-', $category);
         $catID = $this->CreatCategory($category, $tags);
         qa_db_post_set_category($postid, $catID, null, null);
         qa_db_posts_calc_category_path($postid);
         $path = qa_db_post_get_category_path($postid);
         qa_db_category_path_qcount_update($path);
     } else {
         // update category
         $oldpath = qa_db_post_get_category_path($postid);
         $tags = $result['tags'];
         $catID = $result['categoryid'];
         qa_db_post_set_category($postid, $catID, null, null);
         qa_db_posts_calc_category_path($postid);
         $path = qa_db_post_get_category_path($postid);
         qa_db_category_path_qcount_update($oldpath);
         qa_db_category_path_qcount_update($path);
     }
 }
开发者ID:swuit,项目名称:swuit-q2a,代码行数:25,代码来源:it-event.php

示例2: process_request

 function process_request($request)
 {
     // double check we are admin
     if (qa_get_logged_in_level() < QA_USER_LEVEL_ADMIN) {
         return;
     }
     if (qa_clicked('docancel')) {
         qa_redirect('admin/plugins');
     }
     $qa_content = qa_content_prepare();
     $qa_content['title'] = 'Widget Anywhere';
     $qa_content['custom'] = '<p><a href="' . qa_path('admin/plugins') . '#' . qa_html($this->anchor) . '">&laquo; back to plugin options</a></p>';
     $saved_msg = null;
     $editid = qa_get('editid');
     if (qa_post_text('dodelete')) {
         $this->delete_widget();
         qa_redirect('admin/plugins');
     } else {
         if (qa_clicked('save_button')) {
             // save widget
             $widget = $this->save_widget();
             $saved_msg = 'Widget saved.';
         } else {
             if (empty($editid)) {
                 // display blank form
                 $widget = array('id' => 0, 'title' => '', 'pages' => '', 'position' => '', 'ordering' => 1, 'content' => '');
             } else {
                 // load specified widget
                 $sql = 'SELECT * FROM ^' . $this->pluginkey . ' WHERE id=#';
                 $result = qa_db_query_sub($sql, $editid);
                 $widget = qa_db_read_one_assoc($result);
             }
         }
     }
     $sel_position = empty($widget['position']) ? null : @$this->positionlangs[$widget['position']];
     // set up page (template) list
     $widget_pages = explode(',', $widget['pages']);
     $sel_pages = array();
     $custom_pages = array();
     foreach ($widget_pages as $page) {
         if (strpos($page, 'custom:') === 0) {
             $custom_pages[] = substr($page, 7);
         } else {
             $sel_pages[] = $page;
         }
     }
     // $chkd = in_array('all', $sel_pages) ? 'checked' : '';
     // $pages_html = '<label><input type="checkbox" name="wpages_all" ' . $chkd . '> ' . qa_lang_html('admin/widget_all_pages') . '</label><br><br>';
     $pages_html = '';
     foreach ($this->templatelangkeys as $tmpl => $langkey) {
         $chkd = in_array($tmpl, $sel_pages) ? 'checked' : '';
         $pages_html .= '<label><input type="checkbox" name="wpages_' . $tmpl . '" ' . $chkd . '> ' . qa_lang_html($langkey) . '</label><br>';
     }
     $qa_content['form'] = array('tags' => 'METHOD="POST" ACTION="' . qa_self_html() . '"', 'style' => 'tall', 'ok' => $saved_msg, 'fields' => array('title' => array('label' => 'Title', 'tags' => 'NAME="wtitle"', 'value' => qa_html($widget['title'])), 'position' => array('type' => 'select', 'label' => 'Position', 'tags' => 'NAME="wposition"', 'options' => $this->positionlangs, 'value' => $sel_position), 'all_pages' => array('type' => 'checkbox', 'id' => 'tb_pages_all', 'label' => qa_lang_html('admin/widget_all_pages'), 'tags' => 'NAME="wpages_all" ID="wpages_all"', 'value' => in_array('all', $sel_pages)), 'pages' => array('type' => 'custom', 'id' => 'tb_pages_list', 'label' => qa_lang_html('admin/widget_pages_explanation'), 'html' => $pages_html), 'show_custom_pages' => array('type' => 'checkbox', 'id' => 'tb_show_custom_pages', 'label' => 'Show on custom page(s)', 'tags' => 'NAME="cb_custom_pages" ID="cb_custom_pages"', 'value' => count($custom_pages) > 0), 'custom_pages' => array('id' => 'tb_custom_pages', 'label' => 'Page slugs', 'tags' => 'NAME="wpages_custom"', 'value' => qa_html(implode(',', $custom_pages)), 'note' => 'Separate multiple page slugs (URL fragments) with commas, e.g. <code>custom-page,other-page</code>'), 'ordering' => array('type' => 'number', 'label' => 'Order', 'tags' => 'NAME="wordering"', 'value' => qa_html($widget['ordering'])), 'content' => array('type' => 'textarea', 'label' => 'Content (HTML)', 'tags' => 'NAME="wcontent"', 'value' => qa_html($widget['content']), 'rows' => 12)), 'hidden' => array('wid' => $widget['id']), 'buttons' => array('save' => array('tags' => 'NAME="save_button"', 'label' => 'Save widget', 'value' => '1'), 'cancel' => array('tags' => 'NAME="docancel"', 'label' => qa_lang_html('main/cancel_button'))));
     if ($widget['id'] > 0) {
         $qa_content['form']['fields']['delete'] = array('tags' => 'NAME="dodelete"', 'label' => 'Delete widget', 'value' => 0, 'type' => 'checkbox');
     }
     qa_set_display_rules($qa_content, array('tb_pages_list' => '!wpages_all', 'tb_show_custom_pages' => '!wpages_all', 'tb_custom_pages' => 'cb_custom_pages && !wpages_all'));
     return $qa_content;
 }
开发者ID:siddiquinoor,项目名称:q2a-widget-anywhere,代码行数:60,代码来源:qa-widget-anywhere.php

示例3: process_request

 public function process_request($request)
 {
     require_once QA_INCLUDE_DIR . 'qa-app-posts.php';
     // smiley replacement regexes
     $rxSearch = '<(img|a)([^>]+)(src|href)="([^"]+)/wysiwyg-editor/plugins/smiley/images/([^"]+)"';
     $rxReplace = '<$1$2$3="$4/wysiwyg-editor/ckeditor/plugins/smiley/images/$5"';
     qa_suspend_event_reports(true);
     // avoid infinite loop
     // prevent race conditions
     $locks = array('posts', 'categories', 'users', 'users AS lastusers', 'userpoints', 'words', 'titlewords', 'contentwords', 'tagwords', 'words AS x', 'posttags', 'options');
     foreach ($locks as &$tbl) {
         $tbl = '^' . $tbl . ' WRITE';
     }
     qa_db_query_sub('LOCK TABLES ' . implode(',', $locks));
     $sql = 'SELECT postid, title, content FROM ^posts WHERE format="html" ' . 'AND content LIKE "%/wysiwyg-editor/plugins/smiley/images/%" ' . 'AND content RLIKE \'' . $rxSearch . '\' ' . 'LIMIT 5';
     $result = qa_db_query_sub($sql);
     $numPosts = 0;
     while (($post = qa_db_read_one_assoc($result, true)) !== null) {
         $newcontent = preg_replace("#{$rxSearch}#", $rxReplace, $post['content']);
         qa_post_set_content($post['postid'], $post['title'], $newcontent);
         $numPosts++;
     }
     qa_db_query_raw('UNLOCK TABLES');
     qa_suspend_event_reports(false);
     echo $numPosts;
 }
开发者ID:swuit,项目名称:swuit-q2a,代码行数:26,代码来源:qa-wysiwyg-ajax.php

示例4: qa_priv_notification

function qa_priv_notification($uid, $oid, $badge_slug)
{
    require_once QA_INCLUDE_DIR . 'qa-app-users.php';
    require_once QA_INCLUDE_DIR . 'qa-app-emails.php';
    if (QA_FINAL_EXTERNAL_USERS) {
        $publictohandle = qa_get_public_from_userids(array($uid));
        $handle = @$publictohandle[$uid];
    } else {
        $user = qa_db_single_select(qa_db_user_account_selectspec($uid, true));
        $handle = @$user['handle'];
    }
    $subject = qa_opt('badge_email_subject');
    $body = qa_opt('badge_email_body');
    $body = preg_replace('/\\^if_post_text="([^"]*)"/', $oid ? '$1' : '', $body);
    // if post text
    $site_url = qa_opt('site_url');
    $profile_url = qa_path_html('user/' . $handle, null, $site_url);
    if ($oid) {
        $post = qa_db_read_one_assoc(qa_db_query_sub('SELECT * FROM ^posts WHERE postid=#', $oid), true);
        if ($post['parentid']) {
            $parent = qa_db_read_one_assoc(qa_db_query_sub('SELECT * FROM ^posts WHERE postid=#', $post['parentid']), true);
        }
        if (isset($parent)) {
            $anchor = urlencode(qa_anchor($post['basetype'], $oid));
            $post_title = $parent['title'];
            $post_url = qa_path_html(qa_q_request($parent['postid'], $parent['title']), null, qa_opt('site_url'), null, $anchor);
        } else {
            $post_title = $post['title'];
            $post_url = qa_path_html(qa_q_request($post['postid'], $post['title']), null, qa_opt('site_url'));
        }
    }
    $subs = array('^badge_name' => qa_opt('badge_' . $badge_slug . '_name'), '^post_title' => @$post_title, '^post_url' => @$post_url, '^profile_url' => $profile_url, '^site_url' => $site_url);
    qa_send_notification($uid, '@', $handle, $subject, $body, $subs);
}
开发者ID:NoahY,项目名称:q2a-privileges,代码行数:34,代码来源:qa-plugin.php

示例5: mp_get_categoryinfo

function mp_get_categoryinfo($categoryid)
{
    /*
     * Returns all the information for $categoryid
     *
     */
    return qa_db_read_one_assoc(qa_db_query_sub('SELECT * FROM ^categories WHERE categoryid = #', $categoryid), true);
}
开发者ID:TheProjecter,项目名称:microprobe,代码行数:8,代码来源:mp-db-users.php

示例6: qa_db_blob_read

function qa_db_blob_read($blobid)
{
    if (qa_to_override(__FUNCTION__)) {
        $args = func_get_args();
        return qa_call_override(__FUNCTION__, $args);
    }
    return qa_db_read_one_assoc(qa_db_query_sub('SELECT content, format, filename FROM ^blobs WHERE blobid=#', $blobid), true);
}
开发者ID:netham91,项目名称:question2answer,代码行数:8,代码来源:qa-db-blobs.php

示例7: custom_badges_rebuild

 function custom_badges_rebuild()
 {
     $awarded = 0;
     $userq = qa_db_query_sub('SELECT user_id, meta_value FROM ^usermeta WHERE meta_key=$', 'max_bookmarks');
     while (($user = qa_db_read_one_assoc($userq, true)) !== null) {
         $badges = array('bookmarker', 'bookkeeper', 'bookworm');
         $awarded += count(qa_badge_award_check($badges, (int) $user['meta_value'], $user['user_id'], null, 2));
     }
     return $awarded;
 }
开发者ID:NoahY,项目名称:q2a-bookmarks,代码行数:10,代码来源:qa-bookmarks-admin.php

示例8: custom_badges_rebuild

 function custom_badges_rebuild()
 {
     $awarded = 0;
     $posts = qa_db_query_sub('SELECT userid, postid, netvotes FROM ^posts WHERE type=$ AND netvotes>0', 'C');
     while (($post = qa_db_read_one_assoc($posts, true)) !== null) {
         $badges = array('nice_comment', 'good_comment', 'excellent_comment');
         $awarded += count(qa_badge_award_check($badges, (int) $post['netvotes'], $post['userid'], $post['postid'], 2));
     }
     return $awarded;
 }
开发者ID:neil-zeng,项目名称:q2a-comment-voting,代码行数:10,代码来源:qa-comment-voting-admin.php

示例9: mp_get_contribution_points_by_userid

function mp_get_contribution_points_by_userid($userid, $categoryid)
{
    // retrieve raw points data
    $Qpoints = qa_db_read_one_assoc(qa_db_query_sub('SELECT 500 * COUNT(P.postid) points, 100 * COALESCE(SUM(P.upvotes),0) upvotes, 100 * COALESCE(SUM(P.downvotes),0) downvotes
								 FROM ^posts P
								 WHERE type = "Q" and categoryid = # and userid = #', $categoryid, $userid));
    $Apoints = qa_db_read_one_assoc(qa_db_query_sub('SELECT 500 * COUNT(P.postid) points, 100 * COALESCE(SUM(P.upvotes),0) upvotes, 100 * COALESCE(SUM(P.downvotes),0) downvotes
								 FROM ^posts P
								 WHERE type = "A" AND categoryid = # AND userid = #', $categoryid, $userid));
    return $Apoints['points'] + $Apoints['upvotes'] - $Apoints['downvotes'];
}
开发者ID:TheProjecter,项目名称:microprobe,代码行数:11,代码来源:mp-db-points.php

示例10: getUsername

/**
 *通过用户的id找到提问者的用户名
 */
function getUsername($userid)
{
    $query = "SELECT * FROM ^users WHERE userid=\$";
    $arr = qa_db_query_sub($query, $userid);
    $result = qa_db_read_one_assoc($arr);
    if (count($result)) {
        return $result['handle'];
    } else {
        return null;
    }
}
开发者ID:GitFuture,项目名称:bmf,代码行数:14,代码来源:qa_base.php

示例11: qa_db_category_child_depth

function qa_db_category_child_depth($categoryid)
{
    // This is potentially a very slow query since it counts all the multi-generational offspring of a particular category
    // But it's only used for admin purposes when moving a category around so I don't think it's worth making more efficient
    // (Incidentally, this could be done by keeping a count for every category of how many generations of offspring it has.)
    $result = qa_db_read_one_assoc(qa_db_query_sub('SELECT COUNT(child1.categoryid) AS count1, COUNT(child2.categoryid) AS count2, COUNT(child3.categoryid) AS count3 FROM ^categories AS child1 LEFT JOIN ^categories AS child2 ON child2.parentid=child1.categoryid LEFT JOIN ^categories AS child3 ON child3.parentid=child2.categoryid WHERE child1.parentid=#;', $categoryid));
    for ($depth = QA_CATEGORY_DEPTH - 1; $depth >= 1; $depth--) {
        if ($result['count' . $depth]) {
            return $depth;
        }
    }
    return 0;
}
开发者ID:TheProjecter,项目名称:microprobe,代码行数:13,代码来源:qa-db-admin.php

示例12: output_widget

 function output_widget($region, $place, $themeobject, $template, $request, $qa_content)
 {
     $temp = qa_db_query_sub('SELECT BINARY title as title, postid, netvotes, acount FROM ^posts WHERE type=$', 'Q');
     $max = mysqli_num_rows($temp);
     if (!$max) {
         return;
     }
     $themeobject->output('<h2>' . qa_opt('random_question_title') . '</h2>');
     for ($i = 0; $i < qa_opt('random_question_number'); $i++) {
         $rand = rand() / getrandmax() * $max;
         $check = mysqli_data_seek($temp, $rand);
         if (!$check) {
             $i--;
         } else {
             $random_question = qa_db_read_one_assoc($temp, true);
         }
         if (is_array($random_question)) {
             $votes = (int) $random_question['netvotes'];
             if ($votes > 0) {
                 if ($votes > 1) {
                     $votes = str_replace('^', '+' . $votes, qa_lang('main/x_votes'));
                 } else {
                     $votes = str_replace('1', '+1', qa_lang('main/1_vote'));
                 }
             } else {
                 if ($votes < 0) {
                     if ($votes < -1) {
                         $votes = str_replace('^', $votes, qa_lang('main/x_votes'));
                     } else {
                         $votes = str_replace('1', '-1', qa_lang('main/1_vote'));
                     }
                 } else {
                     $votes = '';
                 }
             }
             $answers = (int) $random_question['acount'];
             if ($answers > 0) {
                 if ($answers > 1) {
                     $answers = str_replace('^', '+' . $answers, qa_lang('main/x_answers'));
                 } else {
                     $answers = qa_lang('main/1_answer');
                 }
             } else {
                 $answers = '';
             }
             $themeobject->output('<div class="random-question" style="padding-bottom:4px;"><a href="' . qa_path_html(qa_q_request($random_question['postid'], $random_question['title'])) . '">' . $random_question['title'] . '</a></div><div class="random-question-meta" style="padding-bottom:4px; border-bottom:1px solid; margin-bottom:2px;">' . $votes . ($votes && $answers ? ', ' : '') . $answers . '</div>');
         }
     }
 }
开发者ID:luchenn,项目名称:qa-random-question,代码行数:49,代码来源:qa-random-question.php

示例13: sendEmail

 function sendEmail($event, $userid, $handle, $params)
 {
     $email = $this->getEmail($userid);
     if ($email == qa_opt('feedback_email')) {
         return;
     }
     $parent = qa_db_read_one_assoc(qa_db_query_sub('SELECT * FROM ^posts WHERE postid=#', $params['parentid']), true);
     if ($parent['type'] == 'A') {
         $parent = qa_db_read_one_assoc(qa_db_query_sub('SELECT * FROM ^posts WHERE postid=#', $parent['parentid']), true);
     }
     $url = qa_q_path($parent['postid'], $parent['title'], true, $event == 'a_post' ? 'A' : 'C', $params['postid']);
     $title = $parent['title'];
     $type = $event == 'a_post' ? 'answer' : 'comment';
     $subs = array();
     qa_send_notification(null, qa_opt('feedback_email'), null, qa_lang('admin_plus/posted_subject'), qa_lang('admin_plus/posted_body'), array('^post_handle' => isset($handle) ? $handle : qa_lang('main/anonymous'), '^post_type' => $type, '^post_title' => $title, '^post_content' => $params['content'], '^site_url' => qa_opt('site_url'), '^url' => $url));
 }
开发者ID:NoahY,项目名称:q2a-admin-plus,代码行数:16,代码来源:qa-admin-check.php

示例14: doctype

 function doctype()
 {
     if (@$this->content['error'] == qa_lang_html('main/page_not_found') && preg_match('/^[0-9]+\\//', $this->request) !== false) {
         $pid = preg_replace('/\\/.*/', '', $this->request);
         $merged = qa_db_read_one_assoc(qa_db_query_sub("SELECT ^posts.postid as postid,^posts.title as title FROM ^postmeta, ^posts WHERE ^postmeta.meta_key='merged_with' AND ^postmeta.post_id=# AND ^posts.postid=^postmeta.meta_value", $pid), true);
         if ($merged) {
             qa_redirect(qa_q_request($merged['postid'], $merged['title']), array('merged' => $pid));
         }
     } else {
         if (qa_get('merged')) {
             $this->content['error'] = str_replace('^post', qa_get('merged'), qa_opt('merge_question_merged'));
         }
     }
     if (qa_post_text('ajax_merge_get_from')) {
         return;
     }
     qa_html_theme_base::doctype();
 }
开发者ID:NoahY,项目名称:q2a-post-merge,代码行数:18,代码来源:qa-merge-layer.php

示例15: get_next_q

        function get_next_q()
        {
            $myurl = $this->request;
            $myurlpieces = explode("/", $myurl);
            $myurl = $myurlpieces[0];
            if (is_numeric($myurl)) {
                $query_n = "SELECT ^posts.*,^categories.position\n\tFROM ^posts INNER JOIN ^categories ON ^posts.categoryid = ^categories.categoryid\n\tWHERE postid = {$myurl}\n\tAND type='Q'\n\tLIMIT 1";
                $current_q = qa_db_query_sub($query_n);
                while ($current_link = qa_db_read_one_assoc($current_q, true)) {
                    $categoryid = $current_link['categoryid'];
                    $categoryposition = $current_link['position'];
                }
                $combinedid = $categoryposition * 1000000 - $myurl;
                $query_n = "SELECT ^posts.* \n\tFROM ^posts INNER JOIN ^categories ON ^posts.categoryid = ^categories.categoryid\n\tWHERE position*1000000-postid > {$combinedid} \n\tAND type='Q'\n\tORDER BY position*1000000-postid ASC\n\tLIMIT 1";
                $next_q = qa_db_query_sub($query_n);
                while ($next_link = qa_db_read_one_assoc($next_q, true)) {
                    $title = $next_link['title'];
                    $pid = $next_link['postid'];
                    $this->output('
	<A HREF="' . qa_q_path_html($pid, $title) . '" title="' . $title . '" STYLE="float:right;padding-right:20px">Next Action <img style="border:0px;width:50px" src="../qa-theme/GreenTheme-CATO/next.png"/></A>', '');
                }
            }
        }
开发者ID:ruuttt,项目名称:question2answer,代码行数:23,代码来源:qa-theme.php


注:本文中的qa_db_read_one_assoc函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。