public function selecionar($id = null, $condicao = null) { if ($id != null && $condicao == null) { $sql = sprintf('SELECT * FROM usuarios WHERE id="%s";', $id); } elseif ($id == null && $condicao != null) { $sql = sprintf('SELECT * FROM usuarios WHERE %s;', $condicao); } else { $sql = sprintf('SELECT * FROM usuarios;'); } $objVO = new usuarioVO(); $resultado = array(); $query = $this->executaSQL($sql); while ($rs = mysql_fetch_assoc($query)) { $objVO->setidusuario(stripslashes($rs['id'])); $objVO->setnome(stripslashes($rs['nome'])); $objVO->setemail(stripslashes($rs['email'])); $objVO->setlogin(stripslashes($rs['login'])); $objVO->setsenha(stripslashes($rs['senha'])); $resultado[] = clone $objVO; } return $resultado; }
<?php require_once "classes/usuarioVO.class.php"; require_once "classes/usuarioDAO.class.php"; $user1 = new usuarioVO(); $user1->setidusuario('1'); $user1->setnome('Jao silva'); $user1->setemail('*****@*****.**'); $user1->setlogin('jao'); $user1->setsenha('7894613'); $teste1 = new usuarioDAO(); $atualizado = $teste1->atualizar($user1);
<?php require_once "classes/usuarioVO.class.php"; require_once "classes/usuarioDAO.class.php"; $user1 = new usuarioVO(); $user1->setidusuario('1'); $teste1 = new usuarioDAO(); $excuido = $teste1->deletar($user1);
<?php require_once "classes/usuarioVO.class.php"; require_once "classes/usuarioDAO.class.php"; $user1 = new usuarioVO(); $user1->setnome('Jefferson Lima'); $user1->setemail('*****@*****.**'); $user1->setlogin('jeff'); $user1->setsenha('12345555'); $teste1 = new usuarioDAO(); $inserido = $teste1->inserir($user1); echo $inserido->getidusuario();