当前位置: 首页>>代码示例>>PHP>>正文


PHP Doctrine_Record::getModified方法代码示例

本文整理汇总了PHP中Doctrine_Record::getModified方法的典型用法代码示例。如果您正苦于以下问题:PHP Doctrine_Record::getModified方法的具体用法?PHP Doctrine_Record::getModified怎么用?PHP Doctrine_Record::getModified使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine_Record的用法示例。


在下文中一共展示了Doctrine_Record::getModified方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: validateRecord

 /**
  * Validates a given record and saves possible errors in Doctrine_Validator::$stack
  *
  * @param  Doctrine_Record $record
  * @return void
  */
 public function validateRecord(Doctrine_Record $record)
 {
     $table = $record->getTable();
     // if record is transient all fields will be validated
     // if record is persistent only the modified fields will be validated
     $fields = $record->exists() ? $record->getModified() : $record->getData();
     foreach ($fields as $fieldName => $value) {
         $table->validateField($fieldName, $value, $record);
     }
 }
开发者ID:googlecode-mirror,项目名称:orso,代码行数:16,代码来源:Validator.php

示例2: enforceTemporalModConstraints

 /**
  * enforces the "can't modify the past" rules
  *
  * @param $record
  * @return null
  */
 private function enforceTemporalModConstraints(Doctrine_Record &$record)
 {
     $today = date($this->date_format);
     $modified_table = $record->getTable()->getComponentName();
     $modified_from = $record->getModified(true);
     $modified_to = $record->getModified();
     $problem = false;
     if (@$modified_from[$this->_options['eff_date']] && $modified_from[$this->_options['eff_date']] < $today) {
         $problem = 'from effective';
         $date = $modified_from[$this->_options['eff_date']];
     } elseif (@$modified_from[$this->_options['exp_date']] && $modified_from[$this->_options['exp_date']] < $today) {
         $problem = 'from expiration';
         $date = $modified_from[$this->_options['exp_date']];
     } elseif (!is_null($record[$this->_options['exp_date']]) && $record[$this->_options['exp_date']] < $today) {
         $problem = 'expiration';
         $date = $record[$this->_options['exp_date']];
     }
     if ($problem) {
         throw new Doctrine_Temporal_PastModificationException("Won't modify past {$modified_table} {$problem} date: " . $date);
     }
     // now, check for modification of a current record OTHER THAN SETTING EXP_DATE
     if ($record[$this->_options['eff_date']] < $today) {
         foreach ($modified_to as $k => &$v) {
             // let the exp_date change, since it doesn't have any effect on the past
             if ($k == $this->_options['exp_date']) {
                 continue;
             }
             // make sure the value has actually changed (sometimes re-setting the same value will give a false positive)
             if ($v == $record[$k]) {
                 continue;
             }
             // some other modified field was found, which is not allowed (since it would affect the past)
             throw new Doctrine_Temporal_PastModificationException("Won't modify current record (except terminating it). Requested to save {$k} = {$v} as of {$today}.");
         }
     }
 }
开发者ID:JoshuaEstes,项目名称:sfDoctrineExtraPlugin,代码行数:42,代码来源:Temporal.php

示例3: validateRecord

 /**
  * validates a given record and saves possible errors
  * in Doctrine_Validator::$stack
  *
  * @param Doctrine_Record $record
  * @return void
  */
 public function validateRecord(Doctrine_Record $record)
 {
     $columns = $record->getTable()->getColumns();
     $component = $record->getTable()->getComponentName();
     $errorStack = $record->getErrorStack();
     // if record is transient all fields will be validated
     // if record is persistent only the modified fields will be validated
     $data = $record->exists() ? $record->getModified() : $record->getData();
     $err = array();
     foreach ($data as $key => $value) {
         if ($value === self::$_null) {
             $value = null;
         } elseif ($value instanceof Doctrine_Record) {
             $value = $value->getIncremented();
         }
         $column = $columns[$key];
         if ($column['type'] == 'enum') {
             $value = $record->getTable()->enumIndex($key, $value);
             if ($value === false) {
                 $errorStack->add($key, 'enum');
                 continue;
             }
         }
         if ($record->getTable()->getAttribute(Doctrine::ATTR_AUTO_LENGTH_VLD)) {
             if (!$this->validateLength($column, $key, $value)) {
                 $errorStack->add($key, 'length');
                 continue;
             }
         }
         foreach ($column as $name => $args) {
             if (empty($name) || $name == 'primary' || $name == 'protected' || $name == 'autoincrement' || $name == 'default' || $name == 'values' || $name == 'sequence' || $name == 'zerofill') {
                 continue;
             }
             if (strtolower($name) == 'length') {
                 if (!$record->getTable()->getAttribute(Doctrine::ATTR_AUTO_LENGTH_VLD)) {
                     if (!$this->validateLength($column, $key, $value)) {
                         $errorStack->add($key, 'length');
                     }
                 }
                 continue;
             }
             if (strtolower($name) == 'type') {
                 if (!$record->getTable()->getAttribute(Doctrine::ATTR_AUTO_TYPE_VLD)) {
                     if (!self::isValidType($value, $column['type'])) {
                         $errorStack->add($key, 'type');
                     }
                 }
                 continue;
             }
             $validator = self::getValidator($name);
             if (!$validator->validate($record, $key, $value, $args)) {
                 $errorStack->add($key, $name);
                 //$err[$key] = 'not valid';
                 // errors found quit validation looping for this column
                 //break;
             }
         }
         if ($record->getTable()->getAttribute(Doctrine::ATTR_AUTO_TYPE_VLD)) {
             if (!self::isValidType($value, $column['type'])) {
                 $errorStack->add($key, 'type');
                 continue;
             }
         }
     }
 }
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:72,代码来源:Validator.php

示例4: isValid

 /**
  * @return bool
  */
 public function isValid()
 {
     $tableColumns = $this->_table->getColumns();
     $dirtyColumns = $this->_data->getModified();
     foreach ($dirtyColumns as $key => $value) {
         unset($dirtyColumns[$key]);
         $dirtyColumns[strtolower($key)] = $value;
     }
     #die(Zend_Debug::dump($tableColumns));
     foreach ($tableColumns as $columnName => $columnStructure) {
         if (array_key_exists($columnName, $dirtyColumns)) {
             $validatorChain = new Zend_Validate();
             // Notnull
             if (array_key_exists('notnull', $columnStructure)) {
                 $validatorChain->addValidator(new Zend_Validate_NotEmpty(array('string' => true, 'empty_array' => true, 'null' => true, 'space' => true)));
             }
             // Email
             if (array_key_exists('email', $columnStructure)) {
                 $validatorChain->addValidator(new Zend_Validate_EmailAddress());
             }
             // Notblank
             if (array_key_exists('notblank', $columnStructure)) {
                 $validatorChain->addValidator(new Kebab_Validate_NotBlank());
             }
             // Nospace
             if (array_key_exists('nospace', $columnStructure)) {
                 // check null
                 $validatorChain->addValidator(new Zend_Validate_NotEmpty(array('null' => true)));
                 // check space
                 $validatorChain->addValidator(new Zend_Validate_Regex(array('pattern' => '/\\s/')));
             }
             // Past
             // Future
             // Min Length
             if (array_key_exists('minlength', $columnStructure)) {
                 $validatorChain->addValidator(new Zend_Validate_GreaterThan(array('min' => $columnStructure['minlength'])));
             }
             // Country
             // Ip
             if (array_key_exists('ip', $columnStructure)) {
                 $validatorChain->addValidator(new Zend_Validate_Ip());
             }
             // HtmlColor
             // Range
             if (array_key_exists('range', $columnStructure)) {
                 $validatorChain->addValidator(new Zend_Validate_Between(array('min' => $columnStructure['range'][0], 'max' => $columnStructure['range'][1])));
             }
             //Unique
             if (array_key_exists('unique', $columnStructure)) {
                 $validatorChain->addValidator(new Kebab_Validate_Unique($columnName, $this->_data));
             }
             // Regex
             if (array_key_exists('regexp', $columnStructure)) {
                 $validatorChain->addValidator(new Zend_Validate_Regex(array('pattern' => $columnStructure['regexp'])));
             }
             // Digits
             if (array_key_exists('digits', $columnStructure)) {
                 $validatorChain->addValidator(new Zend_Validate_Digits());
             }
             // Date
             if (array_key_exists('date', $columnStructure)) {
                 $validatorChain->addValidator(new Zend_Validate_Date());
             }
             // CC
             if (array_key_exists('cc', $columnStructure)) {
                 $validatorChain->addValidator(new Zend_Validate_CreditCard());
             }
             // Unsigned
             // Check All
             if (!$validatorChain->isValid($dirtyColumns[$columnName])) {
                 $translator = Zend_Registry::get('Zend_Translate');
                 Zend_Validate_Abstract::setDefaultTranslator($translator);
                 $this->_errors[$columnName] = $validatorChain->getMessages();
             }
             unset($validatorChain);
         }
     }
     if (count($this->_errors) > 0) {
         return false;
     } else {
         return true;
     }
 }
开发者ID:esironal,项目名称:kebab-project,代码行数:86,代码来源:DoctrineTable.php


注:本文中的Doctrine_Record::getModified方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。