| 1 |
<?php |
| 2 |
/** |
| 3 |
* |
| 4 |
*/ |
| 5 |
|
| 6 |
// Disallow direct access. |
| 7 |
defined('ABSPATH') or die("Access denied"); |
| 8 |
|
| 9 |
// Import dependencies. |
| 10 |
cssJSToolbox::import('framework:db:mysql:table.inc.php'); |
| 11 |
|
| 12 |
/** |
| 13 |
* |
| 14 |
*/ |
| 15 |
class CJTBackupsTable extends CJTTable { |
| 16 |
|
| 17 |
/** |
| 18 |
* put your comment there... |
| 19 |
* |
| 20 |
*/ |
| 21 |
public function __construct($dbDriver) { |
| 22 |
parent::__construct($dbDriver, cssJSToolbox::$config->database->tables->backups); |
| 23 |
} |
| 24 |
|
| 25 |
/** |
| 26 |
* put your comment there... |
| 27 |
* |
| 28 |
* @param mixed $key |
| 29 |
*/ |
| 30 |
public function delete($key) { |
| 31 |
// Where clause filters. |
| 32 |
$where = ''; |
| 33 |
$key = $this->prepareQueryParameters($key); |
| 34 |
$key = implode(' AND ', $key); |
| 35 |
if ($key) { |
| 36 |
$where = " WHERE {$key}"; |
| 37 |
} |
| 38 |
// Delete backup. |
| 39 |
$query = "DELETE FROM {$this->table}{$where}"; |
| 40 |
$this->dbDriver->delete($query); |
| 41 |
} |
| 42 |
|
| 43 |
/** |
| 44 |
* put your comment there... |
| 45 |
* |
| 46 |
* @param mixed $type |
| 47 |
*/ |
| 48 |
public function get($type) { |
| 49 |
// Select all backups for specific backup type. |
| 50 |
$query = "SELECT id, name, owner, created |
| 51 |
FROM {$this->table} |
| 52 |
WHERE type = '{$type}'"; |
| 53 |
// Use id field as array key. |
| 54 |
$backups = $this->dbDriver->select($query, OBJECT); |
| 55 |
return $backups; |
| 56 |
} |
| 57 |
|
| 58 |
/** |
| 59 |
* put your comment there... |
| 60 |
* |
| 61 |
* @param mixed $backup |
| 62 |
*/ |
| 63 |
public function insert($data) { |
| 64 |
// Prepare insert statement fields. |
| 65 |
$data = $this->prepareQueryParameters($data); |
| 66 |
$data = implode(',', $data); |
| 67 |
// Build insert statement. |
| 68 |
$query = "INSERT INTO {$this->table} SET {$data}"; |
| 69 |
$this->dbDriver->insert($query); |
| 70 |
} |
| 71 |
|
| 72 |
} // End class. |