public function changeType($currentType, $newType)
{
if ($currentType == $newType) {
return true;
}
$value = new AttributeValue();
$currentCol = $value->column($currentType);
$newCol = $value->column($newType);
if ($currentCol == $newCol) {
return true;
}
$transaction = Yii::app()->getDb()->beginTransaction();
try {
Yii::app()->getDb()->createCommand(sprintf('UPDATE {{store_product_attribute_value}} SET %s = %s WHERE attribute_id = :id', $newCol, $currentCol))->bindValue(':id', $this->id)->execute();
Yii::app()->getDb()->createCommand(sprintf('UPDATE {{store_product_attribute_value}} SET %s = null WHERE attribute_id = :id', $currentCol))->bindValue(':id', $this->id)->execute();
$transaction->commit();
return true;
} catch (Exception $e) {
$transaction->rollback();
return false;
}
}