테이블에서 정수 값을 선택하고 하나씩 증가 시키려고하지만 결과는 다른 것입니다.정수 추가 추가 이상한 결과
TABLE
id index -> BIG INT(20)
---------- ----------
1 191000000000003
<?php
$sql='SELECT index from table where id='1'';
$q=$this->db->query($sql);
$r=$q->row->array();
$index= $r['index'];
$id=$index+1;
echo $id; // returns 1.91E+14
echo $index; // returns 191000000000003
$id=(int)$transfer_index+1;
var_dump($id); // returns (float) 2147483648
var_dump($transfer_index); // returns string
expected result: 191000000000004
?>
'index'는 MySQL 예약어 http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html이라는 것을 알 수 있습니다. 단지 그것의 지옥에 대해서' table'지만 그 이름은 단지 예제 이름 일뿐입니다. –
난 그냥 내 질문에 익명 column_name을 사용합니다. @ Fred-ii- – xyonme
'$ id'와'$ index'의'var_dump'를 게시 할 수 있습니까? 나는'$ index'가 문자열이라는 사실을 거의 확신하고 있으며, 1을 더할 때 부동 소수로 타입 변환됩니다. "1.91E + 14"는 표준 형식 번호 구문 일뿐입니다. "표준 양식"이 문제인 경우 [이 질문]을보십시오. (http://stackoverflow.com/questions/1471674/why-is-php-printing-my-number-in-scientific-notation-when -i-specified-it-as-00) – Scopey