-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEmpresa.php
165 lines (143 loc) · 3.7 KB
/
Empresa.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<?php
class Empresa {
private $id_compania, $nome, $nome_fantasia, $cnpj;
public function Empresa() {}
public function cadastrar($id) {
require 'conectar.php';
$sql = "
INSERT INTO compania
(nome, nome_fantasia, cnpj, id_usuario)
VALUES (
'".$this->getNome()."',
'".$this->getNome_fantasia()."',
'".$this->getCnpj()."',
'$id'
);
";
if($conection->query($sql)) {
$this->setId_compania($conection->insert_id);
$conection->close();
return;
}
echo $conection->error;
return false;
}
public function pegarDados($id) {
require 'conectar.php';
$result = $conection->query("
SELECT id_compania, nome, nome_fantasia, cnpj, id_usuario
FROM compania
WHERE id_usuario = '".$id."'
LIMIT 1
");
return $result;
}
public function deletar() {
require 'conectar.php';
$result = $conection->query("
DELETE FROM compania
WHERE id_compania = '".$this->getId_compania()."';
");
$conection->close();
return $result;
}
public function atualizar() {
require 'conectar.php';
$result = $conection->query("
UPDATE compania
SET nome = '".$this->getNome()."',
nome_fantasia = '".$this->getNome_fantasia()."',
cnpj = '".$this->getCnpj()."'
WHERE id_compania = '".$this->getId_compania()."';
");
$conection->close();
return $result;
}
public function pegarDadosAtribuir($id) {
require 'conectar.php';
$result = $conection->query("
SELECT id_compania, nome, nome_fantasia as fantasia, cnpj
FROM compania
WHERE id_usuario = '".$id."'
LIMIT 1
");
if($row = $result->fetch_assoc()) {
$this->setId_compania($row['id_compania']);
$this->setNome($row['nome']);
$this->setNome_fantasia($row['fantasia']);
$this->setCnpj($row['cnpj']);
return true;
} else {
echo $conection->connect_error;
}
}
/**
* Get the value of nome
*/
public function getNome()
{
return $this->nome;
}
/**
* Set the value of nome
*
* @return self
*/
public function setNome($nome)
{
$this->nome = $nome;
return $this;
}
/**
* Get the value of nome_fantasia
*/
public function getNome_fantasia()
{
return $this->nome_fantasia;
}
/**
* Set the value of nome_fantasia
*
* @return self
*/
public function setNome_fantasia($nome_fantasia)
{
$this->nome_fantasia = $nome_fantasia;
return $this;
}
/**
* Get the value of cnpj
*/
public function getCnpj()
{
return $this->cnpj;
}
/**
* Set the value of cnpj
*
* @return self
*/
public function setCnpj($cnpj)
{
$this->cnpj = $cnpj;
return $this;
}
/**
* Get the value of id_compania
*/
public function getId_compania()
{
return $this->id_compania;
}
/**
* Set the value of id_compania
*
* @return self
*/
public function setId_compania($id_compania)
{
$this->id_compania = $id_compania;
return $this;
}
}
?>