Login   Register  
PHP Classes
elePHPant
Icontem

File: DATA/InvalidDecimal.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Martin Alterisio  >  DATA  >  DATA/InvalidDecimal.php  >  Download  
File: DATA/InvalidDecimal.php
Role: Class source
Content type: text/plain
Description: An exception thrown when a sql decimal field is filled with an invalid value or has overflown its capacity.
Class: DATA
Access data stored in MySQL tables like arrays
Author: By
Last change: + anonymous access
Date: 2007-09-04 20:20
Size: 2,005 bytes
 

Contents

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

/**
 * An exception thrown when a sql decimal field is filled with an
 * invalid value or has overflown its capacity.
 */
class DATA_InvalidDecimal extends DATA_SQLTypeConstraintFailed {
    
/**
     * How many digits the field could hold.
     * @var int
     */
    
private $expectedPrecision;
    
/**
     * How many digits the field had after decimal point.
     * @var int
     */
    
private $expectedScale;
    
/**
     * The string that failed the constraint.
     * @var string
     */
    
private $providedNumber;
    
    
/**
     * Constructor.
     * 
     * @param int $expectedPrecision How many digits the field could hold.
     * @param int $expectedScale How many digits the field had after decimal point.
     * @param string $providedNumber The string that failed the constraint.
     */
    
public function __construct($expectedPrecision$expectedScale$providedNumber) {
        
parent::__construct("SQL numeric field of $expectedPrecision digits with $expectedScale decimals cannot hold '$providedNumber'");
        
$this->expectedPrecision $expectedPrecision;
        
$this->expectedScale $expectedScale;
        
$this->providedNumber $providedNumber;
    }
    
    
/**
     * Returns how many digits the field could hold.
     * 
     * @return int How many digits the field could hold.
     */
    
public function getExpectedPrecision() {
        return 
$this->expectedPrecision;
    }
    
    
/**
     * Returns how many digits the field had after decimal point.
     * 
     * @return int How many digits the field had after decimal point.
     */
    
public function getExpectedScale() {
        return 
$this->expectedScale;
    }
    
    
/**
     * Returns the string that failed the constraint.
     * 
     * @return string The string that failed the constraint.
     */
    
public function getProvidedNumber() {
        return 
$this->providedNumber;
    }
}
?>