1
我想要按照 http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/types.html 的示例並創建自定義數量類型。 introducting主義2自定義類型
public function convertToDatabaseValue($value, AbstractPlatform $platform)
{
return $value->toDecimal();
}
我保存時收到以下錯誤,當
class Quantity extends Type
{
const QUANTITY = 'quantity'; // modify to match your type name
public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{
return 'decimal(10,2)';
}
public function getName()
{
return self::QUANTITY;
}
}
但是:
FatalErrorException: Error: Call to a member function toDecimal() on a non-object in ...\Types\Quantity.php line 26
我懷疑「return $ value-> toDecimal();」是出於演示的原因 – mentalic 2013-03-26 10:14:28