How do I convert an integer to string in CakePHP? -


in cakephp app when try data this:

    $this->loadmodel('radio');     $posts = $this->radio->find('all'); 

the integers displayed strings (in debug) :

'radio' => array(     'idsong' => '4',     'name' => 'batman',     'title' => 'batman theme song' ), 

why? type int in db. need integers correctly displayed in json files

not sure if there's straightforward solution, change model data using afterfind

something like

public function afterfind($results, $primary = false) {     foreach ($results $key => $val) {         if (isset($val['radio']['idsong'])) {             $results[$key]['radio']['idsong'] = (int)$results[$key]['radio']['idsong'];         }     }     return $results; } 

Comments

Popular posts from this blog

Python Kivy ListView: How to delete selected ListItemButton? -

asp.net mvc 4 - A specified Include path is not valid. The EntityType '' does not declare a navigation property with the name '' -