Update DB.php
This commit is contained in:
parent
b2e67c1804
commit
68c88c7fcf
1 changed files with 5 additions and 5 deletions
10
web/DB.php
10
web/DB.php
|
@ -18,7 +18,7 @@ class DB {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_all_contacts($task = null) {
|
public function get_all_contacts($task = null) {
|
||||||
$query = '
|
$query = '
|
||||||
SELECT c.id, c.surname, c.firstname, c.email, c.phone, c.creation_date, c.active
|
SELECT c.id, c.surname, c.firstname, c.email, c.phone, c.creation_date, c.active
|
||||||
FROM contacts c
|
FROM contacts c
|
||||||
|
@ -33,7 +33,7 @@ class DB {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function get_all_tasks() {
|
public function get_all_tasks() {
|
||||||
$query = '
|
$query = '
|
||||||
SELECT id, host, type, params, creation_date, frequency, last_execution, active
|
SELECT id, host, type, params, creation_date, frequency, last_execution, active
|
||||||
FROM tasks
|
FROM tasks
|
||||||
|
@ -41,7 +41,7 @@ class DB {
|
||||||
return $this->query($query);
|
return $this->query($query);
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_all_history($task = null, $limit = 100) {
|
public function get_all_history($task = null, $limit = 100) {
|
||||||
$args = [
|
$args = [
|
||||||
':limit' => $limit
|
':limit' => $limit
|
||||||
];
|
];
|
||||||
|
@ -60,7 +60,7 @@ class DB {
|
||||||
return $this->query($query, $args);
|
return $this->query($query, $args);
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_task_last_status($task) {
|
public function get_task_last_status($task) {
|
||||||
$result = $this->query('SELECT t.id, th.status FROM tasks_history th JOIN tasks t ON (th.task_id = t.id) WHERE t.id = :task ORDER BY datetime DESC LIMIT 1', [':task' => $task]);
|
$result = $this->query('SELECT t.id, th.status FROM tasks_history th JOIN tasks t ON (th.task_id = t.id) WHERE t.id = :task ORDER BY datetime DESC LIMIT 1', [':task' => $task]);
|
||||||
foreach ($result as $r) {
|
foreach ($result as $r) {
|
||||||
return $r['status'];
|
return $r['status'];
|
||||||
|
@ -68,7 +68,7 @@ class DB {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function query($query, $args = null) {
|
public function query($query, $args = null) {
|
||||||
|
|
||||||
if (! $result = $this->link->prepare($query)) {
|
if (! $result = $this->link->prepare($query)) {
|
||||||
throw new DatabaseException('Cannot prepare query ('.$query.') for execution');
|
throw new DatabaseException('Cannot prepare query ('.$query.') for execution');
|
||||||
|
|
Loading…
Add table
Reference in a new issue