Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I add a decimal field in a Codeigniter Migration File?

When writing a codeigniter migration, I am not sure how to go about adding a field of the decimal type. specifically, how do you define the size of the element that is allowed? For example, how would I define the array to pass to dbforge->add_field() in order to create a field like the following:

price decimal(10,2) not null default 0.00
like image 452
GSto Avatar asked Apr 13 '12 14:04

GSto


2 Answers

'price' => array(
    'type' => 'DECIMAL',
    'constraint' => '10,2',
),
like image 166
kneipp Avatar answered Sep 17 '22 00:09

kneipp


'price' => array(
'type' => 'DECIMAL',
'constraint' => '10,2',
'null' => FALSE,
'default' => 0.00
),
like image 25
Shìpu Ahamed Avatar answered Sep 17 '22 00:09

Shìpu Ahamed