ZendDbSchema
Schema management for Zend Framework
 All Classes Namespaces Functions Pages
Engine.php
1 <?php
30  extends Zend_Validate_Abstract
31 {
32  const ENGINE_EMPTY = 'tableEngineEmpty';
33  const INVALID = 'tableEngineInvalid';
34  const NOT_AVAIBLE = 'tableEngineNotAvaible';
35 
39  protected $_messageTemplates = array(
40  self::ENGINE_EMPTY => "table engine can not be empty",
41  self::INVALID => 'Engine %value% is not valid engine type',
42  self::NOT_AVAIBLE => "Engine %value% is not avaible"
43  );
44 
48  protected $_tableEngines = array(
49  'MYISAM',
50  'MEMORY',
51  'INNODB',
52  'FEDERATED',
53  'BLACKHOLE',
54  'MERGE',
55  'EXAMPLE',
56  'ARCHIVE',
57  'CSV'
58  );
59 
66  public function isValid($value)
67  {
68  $schema = null;
69  if ($value instanceof ZendDbSchema_Db_Schema_Table) {
70  $schema = $value;
71  $value = $schema->__get('engine');
72  }
73 
74  if (empty($value)) {
75  $this->_error(self::ENGINE_EMPTY);
76  return false;
77  }
78  if (!in_array(strtoupper($value), $this->_tableEngines)) {
79  $this->_error(self::INVALID, $value);
80  return false;
81  }
82  return true;
83  }
84 }