PluginProbe
CSS & JavaScript Toolbox / 6.0.11
CSS & JavaScript Toolbox v6.0.11
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
← All changes | tables/block-pins.php +12 -23 126.0.11 View file →
@@ -7,8 +7,11 @@
7 7 * No direct access.
8 8 */
9 9 defined('ABSPATH') or die("Access denied");
10 10
11 +// CJTTable class.
12 +require_once CJTOOLBOX_FRAMEWORK . '/db/mysql/table.inc.php';
13 +
11 14 /**
12 15 *
13 16 */
14 17 class CJTBlockPinsTable extends CJTTable {
@@ -40,27 +43,16 @@
40 43 /**
41 44 * put your comment there...
42 45 *
43 46 * @param mixed $ids
44 - * @param mixed $condition
45 47 */
46 - public function get($ids = array(), $condition = null) {
47 - // Initialize.
48 - $where = array();
49 - // May be single integer.
50 - $ids = (array) $ids;
51 - // Retrieve specific list of IDs.
48 + public function get($ids = array()) {
49 + $where = '';
50 + $ids = (array) $ids; // May be single integer.
52 51 if (!empty($ids)) {
53 52 $ids = implode(',', $ids);
54 - $where[] = "`blockId` IN ({$ids})";
53 + $where = " WHERE `blockId` IN ({$ids})";
55 54 }
56 - // Get CONDITIONS expression.
57 - if ($condition !== null) {
58 - $where = array_merge($where, $this->prepareQueryParameters($condition));
59 - }
60 - // Use WHERE CLAUSE only if there is Ids or Condition specified.
61 - $where = !empty($where) ? (' WHERE ' . implode(' AND ', $where)) : '';
62 - // Get result.
63 55 $query = "SELECT * FROM {$this->table}{$where};";
64 56 return $this->dbDriver->select($query, OBJECT);
65 57 }
66 58
@@ -70,22 +62,19 @@
70 62 * @param mixed $blockId
71 63 * @param mixed $pins
72 64 */
73 65 public function insert($blockId, $pins) {
74 - // Initialize.
75 66 $rows = array();
76 - foreach (((array) $pins) as $pin => $values) {
77 - foreach ($values as $value) {
78 - $rows[] = "({$blockId},'{$pin}', {$value})";
67 + if (!empty($pins)) {
68 + foreach ($pins as $pin => $values) {
69 + foreach ($values as $value) {
70 + $rows[] = "({$blockId},'{$pin}', {$value})";
71 + }
79 72 }
80 - }
81 - // Execute only if there is at least one row to insert.
82 - if (!empty($rows)) {
83 73 $rows = implode(',', $rows);
84 74 $query = "INSERT INTO {$this->table} (`blockId`, `pin`, `value`) VALUES {$rows};";
85 75 $this->dbDriver->insert($query);
86 76 }
87 - // Chaining.
88 77 }
89 78
90 79 /**
91 80 * put your comment there...