Permalink
Browse files

Add "precision" and "mode" options to schema for floats, ensures numb…

…ers are rounded to specified precision before insert/update.
  • Loading branch information...
1 parent 8b09207 commit 4688c96e35fb215ec8459a59f4be69940eac30b7 @colinmollenhour committed Jun 18, 2011
Showing with 7 additions and 0 deletions.
  1. +7 −0 code/Model/Type/Tomongo.php
@@ -22,6 +22,13 @@ public function string($mapping, $value)
public function float($mapping, $value)
{
+ if($mapping->precision) {
+ if($mapping->mode) {
+ return round( (float) $value, (int) $mapping->precision, (int) $mapping->mode);
+ } else {
+ return round( (float) $value, (int) $mapping->precision);
+ }
+ }
return (float) $value;
}

0 comments on commit 4688c96

Please sign in to comment.