手气不错
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) |