PHP Classes
elePHPant
Icontem

File: classes/database/exceptions/column-not-editable-db-exception.php

Recommend this page to a friend!
  Classes of Gonzalo Chumillas  >  Ses Query  >  classes/database/exceptions/column-not-editable-db-exception.php  >  Download  
File: classes/database/exceptions/column-not-editable-db-exception.php
Role: Class source
Content type: text/plain
Description: Custom Exception
Class: Ses Query
Manipulate records retrieved with select queries
Author: By
Last change:
Date: 3 years ago
Size: 1,237 bytes
 

Contents

Class file image Download
<?php

require_once dirname(dirname(__DIR__)) . "/database/exceptions/db-exception.php";

/**
 * class ColumnNotEditableDBException
 */
class ColumnNotEditableDBException extends DBException {
    const
PK_MISSING = 1;
    const
PK_NOT_EDITABLE = 2;
    const
LINK_NOT_EDITABLE = 3;
    const
COMPUTED = 4;
   
    private
$errors = array(
       
"The column `%s` is not editable",
       
"The column `%s` is not editable because the primary key of the table `%s` is missing",
       
"The column `%s` is not editable because the primary key of the table `%s` is not editable",
       
"The column `%s` is not editable because it is linked with a non-editable column",
       
"The column `%s` is not editable because it is a computed field"
   
);
   
   
/**
     * @param DBColumn $column
     * @param int $code = 0
     * @param Exception $previous = NULL
     */
   
public function __construct($column, $code = 0, $previous = NULL) {
       
$table = $column->getTable();
       
$column_name = $column->getFullName();
       
$table_alias = $table != NULL? $table->getAlias() : "";
       
$message = sprintf($this->errors[$code], $column_name, $table_alias);
       
parent::__construct($message, $code, $previous);
    }
}