Login   Register  
PHP Classes
elePHPant
Icontem

File: DATA/SQLTypeConstraintFailed.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/SQLTypeConstraintFailed.php  >  Download  
File: DATA/SQLTypeConstraintFailed.php
Role: Class source
Content type: text/plain
Description: An exception thrown when an sql type constraint fails to apply to a value.
Class: DATA
Access data stored in MySQL tables like arrays
Author: By
Last change: + anonymous access
Date: 7 years ago
Size: 2,061 bytes
 

Contents

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

/**
 * An exception thrown when an sql type constraint fails to apply to a value.
 */
abstract class DATA_SQLTypeConstraintFailed extends DATA_Exception {
    
/**
     * The table name where the constraint occured.
     * @var string
     */
    
private $table;
    
/**
     * The field name where the constraint occured.
     * @var string
     */
    
private $field;
    
    
/**
     * Default constructor.
     * 
     * @param string $message Message of exception.
     * @param int $code Code of exception.
     */
    
public function __construct($message null$code 0) {
        
parent::__construct($message$code);
        
$this->table null;
        
$this->field null;
    }
    
    
/**
     * Gets the table name where the constraint occured.
     * 
     * @return string The table name where the constraint occured.
     */
    
final public function getTable() {
        return 
$this->table;
    }
    
    
/**
     * Gets the field name where the constraint occured.
     * 
     * @return string The field name where the constraint occured.
     */
    
final public function getField() {
        return 
$this->field;
    }
    
    
/**
     * Sets the table name where the constraint occured.
     * 
     * @param string $table The table name where the constraint occured.
     */
    
final public function setTable($table) {
        
$this->table $table;
    }
    
    
/**
     * Sets the field name where the constraint occured.
     * 
     * @param string $field The field name where the constraint occured.
     */
    
final public function setField($field) {
        
$this->field $field;
    }
    
    public function 
__toString() {
        
$oldMessage $this->message;
        if (
$this->table && $this->field) {
            
$this->message "[{$this->table}.{$this->field}] " $this->message;
        }
        
$str parent::__toString();
        
$this->message $oldMessage;
        return 
$str;
    }
}
?>