2012-04-13 5 views
6

codeigniter 마이 그 레이션을 작성할 때 decimal 유형의 필드를 추가하는 방법을 잘 모릅니다. 구체적으로 어떻게 허용되는 요소의 크기를 정의합니까? 예를 들어, 내가 어떻게 다음과 같이 필드를 생성하기 위해 dbforge->add_field()에 전달할 배열을 정의하는 것입니다 : 추가를 편집하는 경우Codeigniter 마이그레이션 파일에 소수 필드를 어떻게 추가합니까?

price decimal(10,2) not null default 0.00 

답변

18
'price' => array(
    'type' => 'DECIMAL', 
    'constraint' => '10,2', 
), 
0
'price' => array('type' => 'DECIMAL(10,2)') 
+1

당신의 대답은 더 유용 할 것 몇 가지 설명. – Blackwood

2
'price' => array(
'type' => 'DECIMAL', 
'constraint' => '10,2', 
'null' => FALSE, 
'default' => 0.00 
), 
관련 문제