/** * Retrieve data in json format * **/ function retrieve($serial_number = '', $section = '') { $out = array(); $where = $section ? 'section=?' : ''; $bindings = $section ? array($section) : array(); $comment = new Comment_model(); if ($section) { if ($comment->retrieve_record($serial_number, $where, $bindings)) { $out = $comment->rs; } } else { foreach ($comment->retrieve_records($serial_number, $where, $bindings) as $obj) { $out[] = $obj->rs; } } $obj = new View(); $obj->view('json', array('msg' => $out)); }