Beispiel #1
0
 /**
  * Handles setting of columns
  * Overriding this method to handle JS style dates
  *
  * @param  string $column Column name
  * @param  mixed  $value  Column value
  * @throws Kohana_Exception
  * @return ORM
  */
 public function set($column, $value)
 {
     if ($column == 'value') {
         // Try to convert W3C format first
         $date = DateTime::createFromFormat(DateTime::W3C, $value);
         // If that failed, try standard strtotime
         if (!$date) {
             $date = date_create($value);
         }
         // Output date in MySQL format
         if ($date) {
             $value = $date->format('Y-m-d H:i:s');
         }
     }
     return parent::set($column, $value);
 }
Beispiel #2
0
 /**
  * Updates or Creates the record depending on loaded()
  * Overriding this method to handle WKT Geometry value
  *
  * @chainable
  * @param  Validation $validation Validation object
  * @return ORM
  */
 public function save(Validation $validation = NULL)
 {
     // Validate before replacing value with Database_Expression
     if (!$this->_valid or $validation) {
         $this->check($validation);
     }
     $original_value = FALSE;
     if (is_string($this->_object['value']) and !empty($this->_object['value'])) {
         $original_value = $this->_object['value'];
         $this->_object['value'] = DB::expr('GeomFromText(:wkt)', array(':wkt' => $this->_object['value']));
     }
     parent::save($validation);
     if ($original_value) {
         $this->_object['value'] = $original_value;
     }
 }
Beispiel #3
0
 /**
  * Rules for the post_decimal model
  *
  * @return array Rules
  */
 public function rules()
 {
     return Arr::merge(parent::rules(), array('value' => array(array('not_empty'), array('decimal'))));
 }
Beispiel #4
0
 /**
  * Rules for the post_varchar model
  *
  * @return array Rules
  */
 public function rules()
 {
     return Arr::merge(parent::rules(), array('value' => array(array('max_length', array(':value', 255)))));
 }
Beispiel #5
0
 /**
  * Rules for the post_text model
  *
  * @return array Rules
  */
 public function rules()
 {
     return Arr::merge(parent::rules(), array('value' => array()));
 }