PHP Classes
Icontem

File: DATA/SQLDecimalFactory.php


  Search   All class groups All class groups   Latest entries Latest entries   Top 10 charts Top 10 charts   Newsletter Newsletter   Blog Blog   Forums Forums   Help FAQ Help FAQ  
  Login   Register  
Recommend this page to a friend! ReTweet ReTweet Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Martin Alterisio  >  DATA  >  DATA/SQLDecimalFactory.php  
File: DATA/SQLDecimalFactory.php
Role: Class source
Content type: text/plain
Description: A concrete factory for inboxing php values into decimal fields.
Class: DATA
Access data stored in MySQL tables like arrays
 

Contents

Class file image Download
<?php
/**
 * @package DATA
 */

/**
 * A concrete factory for inboxing php values into decimal fields.
 */
class DATA_SQLDecimalFactory extends DATA_SQLTypeFactory {
    
/**
     * Flags the type to nullable or not nullable.
     * @var boolean
     */
    
protected $nullable;
    
/**
     * How many digits can hold this field.
     * @var int
     */
    
protected $precision;
    
/**
     * How many digits after the decimal point this field has.
     * @var int
     */
    
protected $scale;
    
    
/**
     * Constructor.
     * 
     * @param boolean $nullable True if the type is nullable.
     */
    
public function __construct($nullable$precision$scale) {
        
$this->nullable $nullable;
        
$this->precision $precision;
        
$this->scale $scale;
    }
    
    
/**
     * Inboxes a value.
     * 
     * Throws {@link DATA_InvalidDecimal}.
     * 
     * @param mixed $value The value.
     * @return DATA_SQLDecimal Inboxed value.
     */
    
public function inbox($value) {
        if (
$value instanceof DATA_SQLDecimal) {
            if (
$this->nullable == $value->isNullable()
             && 
$value->getPrecision() == $this->precision
             
&& $value->getScale() == $this->scale) {
                return 
clone $value;
            }
        }
        if (
$value instanceof DATA_SQLType) {
            
$value $value->outbox();
        }
        return new 
DATA_SQLDecimal($this->nullable$this->precision$this->scale$value);
    }
}
?>

 
  Advertise on this site Advertise on this site   Site map Site map   Statistics Statistics   Site tips Site tips   Privacy policy Privacy policy   Contact Contact  

For more information send a message to :
info at phpclasses dot org.
Copyright (c) Icontem 1999-2009 PHP Classes - PHP Class Scripts
  PHP Book Reviews - Reviews of books and other products