<?php include_once '../../../config.php'; try { $status = 'ERRO'; if (isset($_SESSION['idPessoaProprietario'])) { $obj = new ImovelCategoria(Conf::pegCnxPadrao()); $obj->setDados($_POST); $id = $obj->_salvar(); $id = empty($id) ? $obj->getIdCategoria() : $id; $status = 'OK'; } $retorno = array('status' => $status, 'id' => $id); } catch (PDOException $e) { $retorno = array('status' => 'ERRO'); } echo json_encode($retorno);
<?php $status = 'NO'; $resultados = null; try { include_once '../../../config.php'; if (isset($_SESSION['idPessoaProprietario'])) { $obj = new ImovelCategoria(Conf::pegCnxPadrao()); $obj->_preecheObjeto($_POST['id']); $resultados = array(array('id' => $obj->getIdCategoria(), 'descricao' => $obj->getDescricao())); $status = sizeof($resultados) > 0 ? 'OK' : 'NO'; } } catch (PDOException $e) { $status = 'ERRO'; } echo json_encode(array('status' => $status, 'resultados' => $resultados));