PluginProbe
CSS & JavaScript Toolbox / 6.0.6
CSS & JavaScript Toolbox v6.0.6
trunk 0.3 0.8 10 10.1 11 11.2 11.3 11.4 11.5 11.6 11.7 11.8 11.9 11.9.1 12 12.0 12.0.1 12.0.3 12.0.4 12.0.5 12.0.6 12.0.7 6.0 6.0.11 All 60 releases
css-javascript-toolbox / tables / block-pins.php

block-pins.php in CSS & JavaScript Toolbox 6.0.6, at tables/block-pins.php

107 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 *
4 */
5
6 /**
7 * No direct access.
8 */
9 defined('ABSPATH') or die("Access denied");
10
11 // CJTTable class.
12 require_once CJTOOLBOX_FRAMEWORK . '/db/mysql/table.inc.php';
13
14 /**
15 *
16 */
17 class CJTBlockPinsTable extends CJTTable {
18
19 /**
20 * put your comment there...
21 *
22 */
23 public function __construct(&$dbDriver) {
24 // Inirialize parent class.
25 parent::__construct($dbDriver, cssJSToolbox::$config->database->tables->blockPins, 'blockId');
26 }
27
28 /**
29 * put your comment there...
30 *
31 * @param mixed $ids
32 */
33 public function delete($blocks = array()) {
34 $where = '';
35 $blocks = (array) $blocks; // $blocks may be passed as single integer.
36 if (!empty($blocks)) {
37 $where = ' WHERE `blockId` IN (' . implode(',', ((array) $blocks)) . ')';
38 }
39 $query = "DELETE FROM {$this->table}{$where};";
40 $this->dbDriver->delete($query);
41 }
42
43 /**
44 * put your comment there...
45 *
46 * @param mixed $ids
47 */
48 public function get($ids = array()) {
49 $where = '';
50 $ids = (array) $ids; // May be single integer.
51 if (!empty($ids)) {
52 $ids = implode(',', $ids);
53 $where = " WHERE `blockId` IN ({$ids})";
54 }
55 $query = "SELECT * FROM {$this->table}{$where};";
56 return $this->dbDriver->select($query, OBJECT);
57 }
58
59 /**
60 * put your comment there...
61 *
62 * @param mixed $blockId
63 * @param mixed $pins
64 */
65 public function insert($blockId, $pins) {
66 $rows = array();
67 if (!empty($pins)) {
68 foreach ($pins as $pin => $values) {
69 foreach ($values as $value) {
70 $rows[] = "({$blockId},'{$pin}', {$value})";
71 }
72 }
73 $rows = implode(',', $rows);
74 $query = "INSERT INTO {$this->table} (`blockId`, `pin`, `value`) VALUES {$rows};";
75 $this->dbDriver->insert($query);
76 }
77 }
78
79 /**
80 * put your comment there...
81 *
82 * @param mixed $blockId
83 * @param mixed $pins
84 */
85 public function insertRaw($blockId, $pins) {
86 $rows = array();
87 foreach ($pins as $pin) {
88 $rows[] = "({$blockId},'{$pin->pin}', {$pin->value})";
89 }
90 $rows = implode(',', $rows);
91 $query = "INSERT INTO {$this->table} (`blockId`, `pin`, `value`) VALUES {$rows};";
92 $this->dbDriver->insert($query);
93 }
94
95 /**
96 * put your comment there...
97 *
98 * @param mixed $data
99 */
100 public function update($blockId, $pins) {
101 // Delete old block pins.
102 $this->delete($blockId);
103 // Add new block pins.
104 $this->insert($blockId, $pins);
105 }
106
107 } // End class.