DB sql문 date 관련 한번 봐주세용
본문
gameNum 부분은 ai로 되어있습니다.
excutedTime 은 datetime으로 되어있습니다.
해당 insert문
<?php
include_once('./_common.php');
console.log("tset.php is called");
$gameNum = '0';
$whichFrog= '1';
$jumpNum = '1';
$result = '1';
$excutedTime = date('0000-00-00 00:00:00');
insert_wellgameinfo($whichFrog, $jumpNum, $result, $excutedTime);
/**
* Created by PhpStorm.
* User: develop
* Date: 2016-08-03
* Time: 오후 3:39
*/
?>
오류문
insert into g5_wellgameinfo set whichFrog = 1, jumpNum = 1, result= 1, executedTime = 0000-00-00 00:00:00
1064 : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '00:00:00' at line 5
error file : /g5/bbs/test.php
질문
q1. 첫번째 gameNum 부분은 a.i이므로 insert구문에 넣지 않아도 되는걸까요?
q2. datetime 타입은 sql문으로 사용시 어떤형식으로 해야할까요?
검색실력이 부족해서 이렇게 초보적인 질문글 납깁니다..
답변 2
q1. 구문 넣지 않으셔도 됩니다.
q2. 일부러 포맷을 맞춰서 넣지 마시구요..db에서 기본값으로 '0000-00-00' 으로셋팅하시구
null일경우 그냥 '' 공백으로 처리해주세요..
그럼 됩니다. 끝 ^^
구지 넣으실 필요 없구요... 그냥 '' 빈공백 처리해 주시면 됩니다.!
기본값은 phpMyAdmin에서 셋팅하시면 되구요.!
답변을 작성하시기 전에 로그인 해주세요.