묻고답하기
다음 코드 중 무엇이 잘못된 걸까요?
2014.01.13 23:29
며칠쨰 끙끙대네요.
수동으로 호스팅 DB에 들어가서 레코드를 하나 만든 후에 update함수를 호출하면 update쿼리는 잘 먹는데요.
처음부터 인서트 하려고 하면 암만 해보 잘 안되네요. 뭐가 문제일까요? ㅜㅜ
참고로 채용모듈을 개조하고 있는 중입니다.
또한, 암만 생각해도, 쿼리구문은 제대로 만든것 같거든요.
ㅜㅜ 누가 좀 도와주세요.
* 불러오는 함수 중 일부
//if is a new comment_srl ,then insert the comment. Or update the comment
if($comment->comment_srl != $obj->comment_srl) {
$output = $oCommentController->insertComment($obj, $bAnonymous);
$comment_srl = $output->get('comment_srl');
$insert_extravars = $this->insertJudgeOpinion($comment_srl);
$msg = 'application_success_registed';
} else {
$obj->parent_srl = $comment->parent_srl;
$output = $oCommentController->updateComment($obj);
$comment_srl = $obj->comment_srl;
$update_extravars = $this->_updateApplicantExtraVars($comment_srl);
$msg = 'application_success_updated';
}
* Insert 함수
function insertJudgeOpinion($comment_srl)
{
$vars = Context::getRequestVars();
$args->comment_srl = $comment_srl;
$args->module_srl = $this->module_srl;
$args->applicant_name = '이동근'; //strval($vars->applicant_name);
$args->result = strval($vars->result);
$args->score1 = strval($vars->score1);
$args->score2 = strval($vars->score2);
$args->score3 = strval($vars->score3);
$args->score4 = strval($vars->score4);
$args->score5 = strval($vars->score5);
$args->score6 = strval($vars->score6);
$args->score7 = strval($vars->score7);
$args->mention1 = $vars->mention1;
$args->mention2 = $vars->mention2;
$args->mention3 = strval($vars->mention3);
$args->mention4 = strval($vars->mention4);
$args->mention5 = strval($vars->mention5);
$args->mention6 = strval($vars->mention6);
$args->mention7 = strval($vars->mention7);
$args->comprehensive = strval($vars->comprehensive);
// $args->birth = date('YmdHis', strtotime($vars->birthday));
// $args->phone_no = $vars->phone_number;
// $diff = abs(time()-strtotime($vars->birthday));
// $args->age = intval($diff / (365*60*60*24));
$logged_info = Context::get('logged_info');
if(!$logged_info) $args->member_srl = 0;
else $args->member_srl = $logged_info->member_srl;
$output = executeQuery('paper.insertJudgeOpinion', $args);
return $output;
if (!$output) {
echo("Insert 성공");
}
else {
echo("Insert 실패");
}
$connect = DB::getInstance();
$query = $connect->_query("INSERT INTO xe_paperrating (comment_srl, module_srl, member_srl, applicant_name, result, score1, score1) value ('123', '2333', '4', 'adsf',
'10', $args->score1)");
$result = $connect->_fetch($query);
return $result;
/*
// 직접 제어(XE 인서트 안먹으므로 직접 제어
// if (!$output) {
require $_SERVER['DOCUMENT_ROOT']."/files/config/db.config.php";
// $conn = mysql_connect($db_info->master_db['db_hostname'],$db_info->master_db['db_userid'],$db_info->master_db['db_password'])or die(mysql_error());
// $selc = mysql_select_db($db_info->master_db['db_database'],$conn);
$hostname = "localhost"; // $db_info->master_db['db_hostname'];
$username = "kdfs2013"; // $db_info->master_db['db_userid'];
$password = "daniel81"; // $db_info->master_db['db_password'];
$dbname = "kdfs2013_godohosting_com"; // $db_info->master_db['db_database'];
// $conn = mysqli_connect($hostname, $username, $password) or die("MySQL Server 연결에 실패했습니다");
$connect = mysqli_connect($hostname, $username, $password, $dbname) or die("MySQL Server 연결에 실패했습니다");
mysqli_set_charset($connect, "utf8");
$q = "INSERT INTO xe_paperrating (comment_srl, module_srl, member_srl, applicant_name, result, score1, score1) value ('123', '2333', '4', 'adsf',
'10', $args->score1)";
$r = mysqli_query($connect, $q);
// mysql_close($connect);
*/
}
*update 함수
function _updateApplicantExtraVars($comment_srl)
{
if(!$comment_srl) return new Object(-1, 'msg_invalid_request');
$vars = Context::getRequestVars();
$args->comment_srl = $comment_srl;
$args->applicant_name = strval($vars->applicant_name);
$args->result = strval($vars->result);
$args->score1 = strval($vars->score1);
$args->score2 = strval($vars->score2);
$args->score3 = strval($vars->score3);
$args->score4 = strval($vars->score4);
$args->score5 = strval($vars->score5);
$args->score6 = strval($vars->score6);
$args->score7 = strval($vars->score7);
$args->mention1 = strval($vars->mention1);
$args->mention2 = strval($vars->mention2);
$args->mention3 = strval($vars->mention3);
$args->mention4 = strval($vars->mention4);
$args->mention5 = strval($vars->mention5);
$args->mention6 = strval($vars->mention6);
$args->mention7 = strval($vars->mention7);
$judgeoutput = executeQuery('paper.updateJudgeOpinion', $args);
return $judgeoutput;
}
아.. 그리고 혹시.. 권한 설정에 따라 insert문만 안 먹게 하는 경우가 가능한가요?
혹시 그런 문제가 있나요?