Merged revisions 46566 via svnmerge from

svn://svn.silverstripe.com/silverstripe/modules/sapphire/branches/2.2.0-mesq

........
  r46566 | ischommer | 2007-12-11 10:16:22 +1300 (Tue, 11 Dec 2007) | 1 line
  
  Allowing precision in Float, e.g. "Float(10,5)"
........


git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@52152 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2008-04-04 22:55:38 +00:00
parent abe511fd6c
commit 96a245cb1c

View File

@ -12,8 +12,36 @@
*/
class Float extends DBField {
/**
* Allows for setting the digits before decimal point
* e.g. a value of 7 can be -99999.99
*
* @var int
*/
protected $countTotalDigits;
/**
* Allows for setting the digits before decimal point
* e.g. a value of 4 can be -999.9999
*
* @var int
*/
protected $countDigitsAfterDecimal;
function __construct($name, $countTotalDigits, $countDigitsAfterDecimal) {
$this->countTotalDigits = $countTotalDigits;
$this->countDigitsAfterDecimal = $countDigitsAfterDecimal;
parent::__construct($name);
}
function requireField() {
DB::requireField($this->tableName, $this->name, "float");
if($this->countTotalDigits && $this->countDigitsAfterDecimal) {
$sql = "float({$this->countTotalDigits},{$this->countDigitsAfterDecimal})";
} else {
$sql = "float";
}
DB::requireField($this->tableName, $this->name, $sql);
}
function Nice() {