08.27 php saved
rafaelbandeira3
Tags add more
 
Note
rafaelbandeira3.wordpress.com,
"Using MySQL functions with CakePHP on INSERT":

"Trying to use MySQL functions as field values on Model::save() is really frustrating as they are totally ignored by DboMysql::value(), and treated as strings, as I discoreved diving into DboSource's and DboMysql's [...]"
  1. class DboSource extends DataSource {
  2. [...]
  3.     function value($data, $column = null) {
  4.         if (is_array($data) && !empty($data)) {
  5.             return array_map(array(&$this, 'value'), $data, array_fill(0, count($data), $column));
  6. /*
  7. * Here is where lies the hack
  8. * it's line 137 of cake/libs/model/datasources/dbo_source.php
  9. *
  10. */
  11.         } elseif (is_object($data)) {
  12.             if (isset($data->type) && $data->type == 'identifier') {
  13.                 return $this->name($data->value);
  14.             }
  15.         } elseif (in_array($data, array('{$__cakeID__$}', '{$__cakeForeignKey__$}'), true)) {
  16.             return $data;
  17.         } else {
  18.             return null;
  19.         }
  20.     }
  21. [...]
  22. }
  23.  
Parsed in 0.038 seconds, using GeSHi 1.0.7.14

Modify this Paste