mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
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:
parent
abe511fd6c
commit
96a245cb1c
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user