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 = 'tableNameEmpty';
33  const EXISTS = 'tableExists';
34 
38  protected $_messageTemplates = array(
39  self::NAME_EMPTY => "Table name can not be empty",
40  self::EXISTS => "Table with name %value% alteady exists"
41  );
42 
49  public function isValid($value)
50  {
51  $schema = null;
52  if ($value instanceof ZendDbSchema_Db_Schema_Table) {
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->getAdapter()->hasTable($value)) {
62  $this->_error(self::EXISTS, $value);
63  return false;
64  }
65  }
66  return true;
67  }
68 }