示例#1
0
            //$userDir = util::get_user_directory();
            $categoryArray = $categoryDao->getAllCategory();
            $size = sizeof($categoryArray);
            $jsonstr = '';
            $jsonstr .= '{"message":"success","data":[';
            //for ($x = 0; $x < $size; $x++) {
            //	$category = $categoryArray[$x];
            foreach ($categoryArray as $category) {
                //var_dump($category);
                $jsonstr .= $category->__toString() . ",";
            }
            $jsonstr = substr($jsonstr, 0, -1);
            $jsonstr .= ']}';
            echo json_encode($jsonstr);
        } catch (Exception $e) {
            // echo $e->getMessage();
            $msg = 'failure' . $e->getMessage() . $e->getFile() . $e->getLine();
            $msg = str_replace("\\", "\\\\", $msg);
            $msg = htmlspecialchars($msg);
            echo json_encode('{"message":"' . $msg . '"}');
        }
        //echo $jsonstr;
    } else {
        echo '{"message":"action not found"}';
    }
}
DbUtil::disconnect();
?>