ZendDbSchema
Schema management for Zend Framework
 All Classes Namespaces Functions Pages
Name.php
1 <?php
30  extends Zend_Validate_Abstract
31 {
32  const NAME_EMPTY = 'columnNameEmpty';
33  const EXISTS = 'columnExists';
34 
38  protected $_messageTemplates = array(
39  self::NAME_EMPTY => "Column name can not be empty",
40  self::EXISTS => "Column with name %value% alteady exists in table"
41  );
42 
49  public function isValid($value)
50  {
51  $schema = null;
52  if ($value instanceof ZendDbSchema_Db_Schema_Table_Column) {
53  $schema = $value;
54  $value = $schema->getName();
55  }
56  if (empty($value)) {
57  $this->_error(self::NAME_EMPTY);
58  return false;
59  }
60  if ($schema && $value !== $schema->getOriginName()) {
61  if ($schema->getTable()->columns()->has($value)) {
62  $this->_error(self::EXISTS, $value);
63  return false;
64  }
65  }
66  return true;
67  }
68 }