customer_ideas.php
1.61 KB
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
<?php
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
namespace models;
class customer_ideas extends \db
{
public function addIdea($idea) {
return $this->get(
'
INSERT INTO
public.customer_ideas
(idea_text, customer_id)
VALUES
(:idea_text, :customer_id)
',
[
'idea_text' => $idea['idea_text'],
'customer_id' => $idea['customer_id']
],
-1
);
}
public function getAllData() {
return $this->get(
'
SELECT * FROM
public.customer_ideas
',
[
],
-1
);
}
public function getOneData($id)
{
return $this->get(
'
SELECT customer_ideas.id as id, idea_text, customers.name as customer
FROM public.customer_ideas
INNER JOIN customers
ON customer_ideas.customer_id=customers.id
WHERE
customer_ideas.id = :id
',
[
'id' => $id
],
-1
);
}
public function countData( )
{
return $this->get(
'
SELECT
COUNT(id) AS total
FROM
public.customer_ideas
',
[
],
-1
);
}
}