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


PHP ORM::values方法代码示例

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


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

示例1: update

 /**
  * Function for easy update a ORM object
  *
  * @param ORM $object ORM object to update
  * @param array $messages Array of custom messages
  */
 public function update(ORM $object, array $messages = array())
 {
     // Check if is a valid object
     if (!$object->loaded()) {
         Messages::warning(isset($messages['warning']) ? $messages['warning'] : 'El elemento que intentas modificar no existe o fue eliminado.');
         $this->go();
     }
     // Only if Request is POST
     if ($this->request->method() == Request::POST) {
         // Catch ORM_Validation
         try {
             // Set object values and update
             $object->values($this->request->post())->update();
             // If object is saved....
             if ($object->saved()) {
                 // Success message & redirect
                 Messages::success(isset($messages['success']) ? $messages['success'] : 'El elemento fue modificado correctamente.');
                 $this->go();
             }
         } catch (ORM_Validation_Exception $e) {
             // Error message
             if (isset($messages['error'])) {
                 Messages::error($messages['error']);
             }
             // Validation messages
             Messages::validation($e);
         }
     }
 }
开发者ID:NegoCore,项目名称:core,代码行数:35,代码来源:CRUD.php

示例2: values

 public function values(array $values, array $expected = NULL)
 {
     if (!empty($values['dob-year']) && !empty($values['dob-month']) && !empty($values['dob-day'])) {
         $values['dob'] = $values['dob-year'] . '-' . $values['dob-month'] . '-' . $values['dob-day'];
     }
     return parent::values($values, $expected);
 }
开发者ID:halkeye,项目名称:ecmproject,代码行数:7,代码来源:registration.php

示例3: values

 public function values($post)
 {
     if ($this->_orm) {
         $this->_orm->values($post);
         return $this;
         // Chain the Entity, not the ORM object
     } else {
         throw new Missing_ORM_Exception("There is no ORM object linked to this Entity instance");
     }
 }
开发者ID:spruce-bruce,项目名称:entity,代码行数:10,代码来源:Entity.php

示例4: populate

 /**
  * @return bool
  */
 public function populate()
 {
     if (!$this->allowed('write')) {
         return FALSE;
     }
     $hash = $this->_hash_input_name;
     // nothing or the other form has been submitted
     if (!isset($_POST[$hash])) {
         return FALSE;
     }
     $values = array();
     foreach ($this as $name => $field) {
         if ($field->allowed('write')) {
             if (!is_null($value = Arr::get($_POST, $name))) {
                 $values[$name] = $field->prepare_to_populate($value);
             }
         }
     }
     $this->_object->values($values);
     foreach ($this as $name => $field) {
         $field->set_value($this->_object->{$name});
     }
     $valid = $this->_object->check();
     foreach ($this as $name => $field) {
         $valid = ($valid and $field->validate($this->_object->validate(), $name));
     }
     if ($valid) {
         return TRUE;
     }
     $errors = $this->_object->validate()->errors($this->_messages_file);
     foreach ($errors as $name => $error) {
         if (isset($this[$name])) {
             $this[$name]->set_error($error);
         }
     }
     return FALSE;
 }
开发者ID:ariol,项目名称:adminshop,代码行数:40,代码来源:Orm.php

示例5: values

 /**
  * Set values from an array with support for one-one relationships.  This method should be used
  * for loading in post data, etc.
  *
  * @param  array $values   Array of column => val
  * @param  array $expected Array of keys to take from $values
  * @return ORM
  */
 public function values(array $values, array $expected = NULL)
 {
     //some work on the data ;)
     if (isset($values['title'])) {
         $values['title'] = Text::banned_words($values['title']);
     }
     if (isset($values['description'])) {
         $values['description'] = Text::banned_words($values['description']);
     }
     if (isset($values['price'])) {
         $values['price'] = floatval(str_replace(',', '.', $values['price']));
     }
     //TODO this is ugly as hell!
     // append to $values new custom values
     foreach ($values as $name => $field) {
         // get by prefix
         if (strpos($name, 'cf_') !== false) {
             //checkbox when selected return string 'on' as a value
             if ($field == 'on') {
                 $values[$name] = 1;
             }
             if ($field == '0000-00-00' or $field == "" or $field == NULL or empty($field)) {
                 $values[$name] = NULL;
             }
         }
     }
     return parent::values($values, $expected);
 }
开发者ID:kleitz,项目名称:openclassifieds2,代码行数:36,代码来源:ad.php


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