Page 387 - 2020학년도 MDP과제발표회 자료집 (통신과) (3)
P. 387
우 클라이언트에서 ( re_pass xxx 로 보낼때)
var dataout = "";
var sql = "select * from " + member_id + " where bookname='" + command[1] +
"'"; // 사용자 이름으로 된 테이블에 책이 있는지 확인
var del = "delete from " + member_id + " where bookname='" + command[1] +
"'"; // 사용자 테이블에서 책을 삭제
var updall = "update all_book set location='" + command[2] + "' where
bookname='" + command[1] + "'"; // 모든 책의 정보가 저장된 테이블에 위치를 수정
var select = "select company,writer from all_book where bookname='" +
command[1] + "'"; // 모든 책 테이블에 출판사와 작가 정보를 받아옴
link.query(select, function (err0, result0, fields0) { // 쿼리문 실
행
if (!err0) {
member.query(sql, function (err, result, fields) { // 쿼리문 실
행
if (!err) {
if (result != "") {
socket.write("yes:" + result[0].p_dcheck)
console.log("yes:" + result[0].p_dcheck)
var update = "update " + command[2] + " set bookname='" +
command[1] + "', company='" + result0[0].company + "', writer='" + result0[0].writer + "' where
location='" + command[3] + "'"; // 기계에 책의 정보를 아래칸부터 삽입
link.query(update, function (err1, result1, fields1) { / /
쿼리문 실행
if (!err1) {
console.log(" 반납 완료 데이터 수정 성공, ");
} else {
console.log(" 반납 실패 데이터 삽입 실패 쿼리 에러, ");
console.log('[!] "' + update + '" Query has error!');
}
})
member.query(del, function (err2, result2, fields2) { / /
쿼리문 실행
if (!err2) {
console.log(" 반납 완료 데이터 삭제 성공, ");
} else {
console.log(" 반납 실패 데이터 삭제 실패 쿼리 에러, ");
console.log('[!] "' + del + '" Query has error!');
}
})
link.query(updall, function (err3, result3, fields3) {
if (!err3) {
console.log(" 반납 성공, all_book 수정 성공");
} else {
console.log(" 반납 실패, all_book 수정 실패 쿼리 에러");
인천전자마이스터고등학교
- 403 - 정보통신기기과 403