PDA

View Full Version : $dbalter->add_field Question


TheMayhem
01-06-2010, 09:03 PM
I'm working on finishing up a product I've created and am having a tiny bit of issues with the $dbalter->add_field function. I need to add a field to the usergroup database that can contain decimals. I've tried Double & Decimal (12,2) but haven't had much success. All other fields I've added have worked correctly except when it comes to decimal manipulation. Here is a copy of my code:


// Make vB table alterations
require_once(DIR . '/includes/class_dbalter.php');
$dbalter = new vB_Database_Alter_MySQL($db);

$dbalter->add_field(array(
'name' => 'market_discount',
'type' => 'DOUBLE',
'length' => 8,
'attributes' => 'UNSIGNED',
'null' => false,
'default' => '0'
));
$db->show_errors();


What can I do differently to get the double or even a decimal data type in there to work correctly?

Paul M
01-07-2010, 11:20 AM
Have you tried


$dbalter->add_field(array(
'name' => 'market_discount',
'type' => 'DOUBLE',
'length' => '12,2',
'attributes' => 'UNSIGNED',
'null' => false,
'default' => '0'
));


for the length ?