Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1308572
  • 博文数量: 273
  • 博客积分: 5865
  • 博客等级: 准将
  • 技术积分: 3280
  • 用 户 组: 普通用户
  • 注册时间: 2010-11-11 10:01
文章分类

全部博文(273)

文章存档

2015年(33)

2014年(11)

2013年(11)

2012年(136)

2011年(32)

2010年(50)

分类: Android平台

2014-07-31 14:50:53

手气不错

alter table qa_question_involved change id id int  not null auto_increment

 CREATE TABLE `qa_question_involved` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `question_id` int(11) NOT NULL,
  `involved_um` varchar(30) NOT NULL,
  `involved_action` text NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8 

function qa_db_question_involved_insert($id='',$qid, $um, $action)
{
qa_db_query_sub(
'INSERT ignore INTO ^question_involved (id, question_id, involved_um, involved_action) VALUES (#,#,$,$) ',
null,$qid, $um, $action
);
}


function qa_db_question_involved_select($qid){
$lines=qa_db_read_all_assoc(qa_db_query_sub(
"SELECT involved_um, involved_action FROM ^question_involved WHERE question_id=# ORDER BY involved_um ",
$qid
));
return $lines;
}


vim2 qa-include/qa-tools-question-invovled.php

             require 'qa-base.php';
require_once QA_INCLUDE_DIR.'qa-app-format.php';
require_once QA_INCLUDE_DIR.'qa-db-selects.php';
require_once QA_INCLUDE_DIR.'qa-util-sort.php';
require_once QA_INCLUDE_DIR.'qa-util-string.php';
require_once QA_INCLUDE_DIR.'qa-db-admin.php';


$questionid=$_GET['ID'];
$userid='2';




list($question, $childposts, $achildposts)=qa_db_select_with_pending(
qa_db_full_post_selectspec($userid, $questionid),
qa_db_full_child_posts_selectspec($userid, $questionid),
qa_db_full_a_child_posts_selectspec($userid, $questionid)

);

$line=$question['handle'].' 提问: '.$question['title'].'

';


foreach ($childposts as $key => $value) {
if( $value['type'] == 'A'  ) {
qa_db_question_involved_insert('',$questionid, $value['handle'], '回答');

}
if( $value['type'] == 'C'  ) {
qa_db_question_involved_insert('',$questionid, $value['handle'], '评论');

}
}




foreach ($achildposts as $key => $value) {
qa_db_question_involved_insert('',$questionid, $value['handle'], '评论');


}


$tests=qa_db_question_involved_select($questionid);


foreach ($tests as $test) {
$line.=$test['involved_um'].'        '.$test['involved_action'].'
';
}
echo $line;


?>


阅读(1185) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~