Skip to content

Commit

Permalink
cambio en export
Browse files Browse the repository at this point in the history
  • Loading branch information
Abel Osorio authored and Abel Osorio committed Jan 11, 2013
1 parent 1c95526 commit 72aacb5
Showing 1 changed file with 42 additions and 14 deletions.
56 changes: 42 additions & 14 deletions application/models/usuario_model.php
Expand Up @@ -178,7 +178,7 @@ public function getUserInfoxml($username) {


$this->load->dbutil();
$sql = "select * from usuario";
$sql = "select * from usuario where username = '$username'";
$query = $this->db->query($sql);
$config = array(
'root' => 'root',
Expand All @@ -187,16 +187,45 @@ public function getUserInfoxml($username) {
'tab' => "\t"
);
$xml = $this->dbutil->xml_from_result($query, $config);
if ($xml != null){
// $this->load->helper('download');
//force_download('myfile.xml', $xml);
return true;

}
else{
if ($xml != null) {
// libretas
$sql2 = "select l.id_libreta,l.nombre,l.descripcion,l.fecha from libreta l, usuario u where u.username = '$username' and u.id_usuario = l.fk_usuario";
$query2 = $this->db->query($sql2);
$config2 = array(
'root' => 'libretas',
'element' => 'libreta',
'newline' => "\n",
'tab' => "\t"
);
$xml2 = $this->dbutil->xml_from_result($query2, $config2);
$xml3 = $xml . $xml2;


// notas
$sql3 = "select l.id_libreta,l.nombre,l.descripcion,l.fecha from libreta l, usuario u where u.username = '$username' and u.id_usuario = l.fk_usuario";
$query3 = $this->db->query($sql2);
$config3 = array(
'root' => 'libretas',
'element' => 'libreta',
'newline' => "\n",
'tab' => "\t"
);
$xml4 = $this->dbutil->xml_from_result($query3, $config3);
$xml5 = $xml3 . $xml4;







$this->load->helper('download');
force_download('myfile.xml', $xml3);

return true;
} else {
return false;
}

}

/**
Expand All @@ -223,18 +252,17 @@ public function getUserToken($username) {
}
return false;
}

public function getIDuser($username) {

$this->db->where('username', $username);
public function getIDuser($username) {

$this->db->where('username', $username);
$query = $this->db->get('usuario');
$row2 = $query->row();
if ($row2 != null) {
$id = $row2->id_usuario;
$id = $row2->id_usuario;
return $id;
}
return false;

}

public function deleteuser($username) {
Expand Down

0 comments on commit 72aacb5

Please sign in to comment.