Пример #1
0
 public function validate($value)
 {
     if ($value == null) {
         return true;
     }
     if ($this->length != null && strlen($value) > $this->length) {
         return false;
     } elseif ($this->regex != null && !Core\Tools::match($value, $this->regex)) {
         return false;
     }
     return true;
 }
Пример #2
0
 /**
  * /!\ This method is experimental and should be used only if you know what you are doing.
  * Query chain element, joining provided $table to the query.
  * This method does not require a bound model. 
  * But the downside is that you won't have any object formating or column aliasing, so be careful with overlaps.
  * @param string $link A table name.
  * @param string $leftfield The field from the current table
  * @param string $rightfield The field from the joined table
  * @param string $type [LEFT|RIGHT|INNER|OUTER]
  */
 public function &joinTable($table, $leftfield, $rightfield, $type = 'LEFT')
 {
     if (empty($table) || empty($leftfield) || empty($rightfield)) {
         throw new Core\Exception('Missing arguments while trying to join [' . Core\Security::preventInjection($table) . '].');
     }
     if (!Core\Tools::match($type, '(natural )?((inner|cross)|(left|right)( outer)?)?', 'i')) {
         throw new Core\Exception('Invalid join type while trying to join [' . Core\Security::preventInjection($table) . '].');
     }
     $this->_JOIN_TABLE[$table] = array($leftfield, $rightfield, $type);
     return $this;
 }