Completed
Push — develop ( ae5bdc...8aa11c )
by Bartko
01:50
created

Zend1::insert()   B

Complexity

Conditions 4
Paths 6

Size

Total Lines 28
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 15
CRAP Score 4.0039

Importance

Changes 0
Metric Value
dl 0
loc 28
ccs 15
cts 16
cp 0.9375
rs 8.5806
c 0
b 0
f 0
cc 4
eloc 18
nc 6
nop 2
crap 4.0039
1
<?php
2
3
declare(strict_types=1);
4
5
namespace StefanoTree\NestedSet\Adapter;
6
7
use StefanoTree\NestedSet\NodeInfo;
8
use StefanoTree\NestedSet\Options;
9
use Zend_Db_Adapter_Abstract as ZendDbAdapter;
10
use Zend_Db_Select as ZendDbSelect;
11
12
class Zend1 extends AdapterAbstract implements AdapterInterface
13
{
14
    protected $dbAdapter;
15
16 56
    public function __construct(Options $options, ZendDbAdapter $dbAdapter)
17
    {
18 56
        $this->setOptions($options);
19 56
        $this->setDbAdapter($dbAdapter);
20 56
    }
21
22
    /**
23
     * @param ZendDbAdapter $dbAdapter
24
     */
25 56
    protected function setDbAdapter(ZendDbAdapter $dbAdapter): void
26
    {
27 56
        $this->dbAdapter = $dbAdapter;
28 56
    }
29
30
    /**
31
     * @return ZendDbAdapter
32
     */
33 53
    public function getDbAdapter(): ZendDbAdapter
34
    {
35 53
        return $this->dbAdapter;
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     *
41
     * @return ZendDbSelect
42
     */
43 32
    public function getBlankDbSelect(): ZendDbSelect
44
    {
45 32
        return $this->getDbAdapter()
46 32
            ->select()
47 32
            ->from($this->getOptions()->getTableName());
48
    }
49
50
    /**
51
     * Return default db select. Always new instance.
52
     *
53
     * @return ZendDbSelect
54
     */
55 17
    public function getDefaultDbSelect(): ZendDbSelect
56
    {
57 17
        return $this->getDbSelectBuilder()();
58
    }
59
60
    /**
61
     * {@inheritdoc}
62
     */
63 1
    public function lockTree(): void
64
    {
65 1
        $options = $this->getOptions();
66
67 1
        $dbAdapter = $this->getDbAdapter();
68
69 1
        $select = $this->getBlankDbSelect()
70 1
            ->reset(\Zend_Db_Select::COLUMNS)
71 1
            ->columns(array('i' => $options->getIdColumnName(true)))
72 1
            ->forUpdate(true);
73
74 1
        $dbAdapter->fetchAll($select);
75 1
    }
76
77
    /**
78
     * {@inheritdoc}
79
     */
80 1
    public function beginTransaction(): void
81
    {
82 1
        $this->getDbAdapter()->beginTransaction();
83 1
    }
84
85
    /**
86
     * {@inheritdoc}
87
     */
88 1
    public function commitTransaction(): void
89
    {
90 1
        $this->getDbAdapter()->commit();
91 1
    }
92
93
    /**
94
     * {@inheritdoc}
95
     */
96 1
    public function rollbackTransaction(): void
97
    {
98 1
        $this->getDbAdapter()->rollBack();
99 1
    }
100
101
    /**
102
     * {@inheritdoc}
103
     */
104 3
    public function update($nodeId, array $data): void
105
    {
106 3
        $options = $this->getOptions();
107
108 3
        $dbAdapter = $this->getDbAdapter();
109
110 3
        $data = $this->cleanData($data);
111
112
        $where = array(
113 3
            $dbAdapter->quoteIdentifier($options->getIdColumnName()).' = ?' => $nodeId,
114
        );
115 3
        $dbAdapter->update($options->getTableName(), $data, $where);
116 3
    }
117
118
    /**
119
     * {@inheritdoc}
120
     */
121 4
    public function insert(NodeInfo $nodeInfo, array $data)
122
    {
123 4
        $options = $this->getOptions();
124 4
        $dbAdapter = $this->getDbAdapter();
125
126 4
        $data[$options->getParentIdColumnName()] = $nodeInfo->getParentId();
127 4
        $data[$options->getLevelColumnName()] = $nodeInfo->getLevel();
128 4
        $data[$options->getLeftColumnName()] = $nodeInfo->getLeft();
129 4
        $data[$options->getRightColumnName()] = $nodeInfo->getRight();
130
131 4
        if ($options->getScopeColumnName()) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $options->getScopeColumnName() of type string|null is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
132 1
            $data[$options->getScopeColumnName()] = $nodeInfo->getScope();
133
        }
134
135 4
        $dbAdapter->insert($options->getTableName(), $data);
136
137 4
        if (array_key_exists($options->getIdColumnName(), $data)) {
138 1
            return $data[$options->getIdColumnName()];
139
        } else {
140 3
            if ('' != $options->getSequenceName()) {
141 3
                $lastGeneratedValue = $dbAdapter->lastSequenceId($options->getSequenceName());
142
            } else {
143
                $lastGeneratedValue = $dbAdapter->lastInsertId();
144
            }
145
146 3
            return $lastGeneratedValue;
147
        }
148
    }
149
150
    /**
151
     * {@inheritdoc}
152
     */
153 2
    public function delete($nodeId): void
154
    {
155 2
        $options = $this->getOptions();
156
157 2
        $dbAdapter = $this->getDbAdapter();
158
159
        $where = array(
160 2
            $dbAdapter->quoteIdentifier($options->getIdColumnName()).' = ?' => $nodeId,
161
        );
162
163 2
        $dbAdapter->delete($options->getTableName(), $where);
164 2
    }
165
166
    /**
167
     * {@inheritdoc}
168
     */
169 2
    public function moveLeftIndexes($fromIndex, $shift, $scope = null): void
170
    {
171 2
        $options = $this->getOptions();
172
173 2
        if (0 == $shift) {
174
            return;
175
        }
176
177 2
        $dbAdapter = $this->getDbAdapter();
178 2
        $sql = 'UPDATE '.$dbAdapter->quoteIdentifier($options->getTableName())
179 2
            .' SET '.$dbAdapter->quoteIdentifier($options->getLeftColumnName())
180 2
            .' = '.$dbAdapter->quoteIdentifier($options->getLeftColumnName()).' + :shift'
181 2
            .' WHERE '.$dbAdapter->quoteIdentifier($options->getLeftColumnName()).' > :fromIndex';
182
183 2
        if ($options->getScopeColumnName()) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $options->getScopeColumnName() of type string|null is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
184 1
            $sql .= ' AND '.$dbAdapter->quoteIdentifier($options->getScopeColumnName()).' = '.$dbAdapter->quote($scope);
185
        }
186
187
        $binds = array(
188 2
            ':shift' => $shift,
189 2
            ':fromIndex' => $fromIndex,
190
        );
191 2
        $dbAdapter->prepare($sql)->execute($binds);
192 2
    }
193
194
    /**
195
     * {@inheritdoc}
196
     */
197 2
    public function moveRightIndexes($fromIndex, $shift, $scope = null): void
198
    {
199 2
        $options = $this->getOptions();
200
201 2
        if (0 == $shift) {
202
            return;
203
        }
204
205 2
        $dbAdapter = $this->getDbAdapter();
206
207 2
        $sql = 'UPDATE '.$dbAdapter->quoteIdentifier($options->getTableName())
208 2
            .' SET '.$dbAdapter->quoteIdentifier($options->getRightColumnName())
209 2
            .' = '.$dbAdapter->quoteIdentifier($options->getRightColumnName()).' + :shift'
210 2
            .' WHERE '.$dbAdapter->quoteIdentifier($options->getRightColumnName()).' > :fromIndex';
211
212 2
        if ($options->getScopeColumnName()) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $options->getScopeColumnName() of type string|null is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
213 1
            $sql .= ' AND '.$dbAdapter->quoteIdentifier($options->getScopeColumnName()).' = '.$dbAdapter->quote($scope);
214
        }
215
216
        $binds = array(
217 2
            ':shift' => $shift,
218 2
            ':fromIndex' => $fromIndex,
219
        );
220
221 2
        $dbAdapter->prepare($sql)->execute($binds);
222 2
    }
223
224
    /**
225
     * {@inheritdoc}
226
     */
227 1
    public function updateParentId($nodeId, $newParentId): void
228
    {
229 1
        $options = $this->getOptions();
230
231 1
        $dbAdapter = $this->getDbAdapter();
232
233
        $bind = array(
234 1
            $options->getParentIdColumnName() => $newParentId,
235
        );
236
237
        $where = array(
238 1
            $dbAdapter->quoteIdentifier($options->getIdColumnName()).' = ?' => $nodeId,
239
        );
240 1
        $dbAdapter->update($options->getTableName(), $bind, $where);
241 1
    }
242
243
    /**
244
     * {@inheritdoc}
245
     */
246 2
    public function updateLevels(int $leftIndexFrom, int $rightIndexTo, int $shift, $scope = null): void
247
    {
248 2
        $options = $this->getOptions();
249
250 2
        if (0 == $shift) {
251
            return;
252
        }
253
254 2
        $dbAdapter = $this->getDbAdapter();
255
256 2
        $sql = 'UPDATE '.$dbAdapter->quoteIdentifier($options->getTableName())
257 2
            .' SET '.$dbAdapter->quoteIdentifier($options->getLevelColumnName())
258 2
            .' = '.$dbAdapter->quoteIdentifier($options->getLevelColumnName()).' + :shift'
259 2
            .' WHERE '.$dbAdapter->quoteIdentifier($options->getLeftColumnName())
260 2
            .' >= :leftFrom'.' AND '.$dbAdapter->quoteIdentifier($options->getRightColumnName())
261 2
            .' <= :rightTo';
262
263 2
        if ($options->getScopeColumnName()) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $options->getScopeColumnName() of type string|null is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
264 1
            $sql .= ' AND '.$dbAdapter->quoteIdentifier($options->getScopeColumnName()).' = '.$dbAdapter->quote($scope);
265
        }
266
267
        $binds = array(
268 2
            ':shift' => $shift,
269 2
            ':leftFrom' => $leftIndexFrom,
270 2
            ':rightTo' => $rightIndexTo,
271
        );
272
273 2
        $dbAdapter->prepare($sql)->execute($binds);
274 2
    }
275
276
    /**
277
     * {@inheritdoc}
278
     */
279 2
    public function moveBranch(int $leftIndexFrom, int $rightIndexTo, int $shift, $scope = null): void
280
    {
281 2
        if (0 == $shift) {
282
            return;
283
        }
284
285 2
        $options = $this->getOptions();
286
287 2
        $dbAdapter = $this->getDbAdapter();
288
289 2
        $sql = 'UPDATE '.$dbAdapter->quoteIdentifier($options->getTableName())
290 2
            .' SET '.$dbAdapter->quoteIdentifier($options->getLeftColumnName())
291 2
            .' = '.$dbAdapter->quoteIdentifier($options->getLeftColumnName()).' + :shift, '
292 2
            .$dbAdapter->quoteIdentifier($options->getRightColumnName())
293 2
            .' = '.$dbAdapter->quoteIdentifier($options->getRightColumnName()).' + :shift'
294 2
            .' WHERE '.$dbAdapter->quoteIdentifier($options->getLeftColumnName()).' >= :leftFrom'
295 2
            .' AND '.$dbAdapter->quoteIdentifier($options->getRightColumnName()).' <= :rightTo';
296
297 2
        if ($options->getScopeColumnName()) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $options->getScopeColumnName() of type string|null is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
298 1
            $sql .= ' AND '.$dbAdapter->quoteIdentifier($options->getScopeColumnName()).' = '.$dbAdapter->quote($scope);
299
        }
300
301
        $binds = array(
302 2
            ':shift' => $shift,
303 2
            ':leftFrom' => $leftIndexFrom,
304 2
            ':rightTo' => $rightIndexTo,
305
        );
306
307 2
        $dbAdapter->prepare($sql)->execute($binds);
308 2
    }
309
310
    /**
311
     * {@inheritdoc}
312
     */
313 4
    public function getRoots($scope = null): array
314
    {
315 4
        $options = $this->getOptions();
316
317 4
        $dbAdapter = $this->getDbAdapter();
318
319 4
        $select = $this->getBlankDbSelect()
320 4
            ->where($options->getParentIdColumnName(true).' IS NULL')
321 4
            ->order($options->getIdColumnName(true));
322
323 4
        if (null != $scope && $options->getScopeColumnName()) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $options->getScopeColumnName() of type string|null is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
324 1
            $select->where($options->getScopeColumnName(true).' = ?', $scope);
325
        }
326
327 4
        return $dbAdapter->fetchAll($select);
328
    }
329
330
    /**
331
     * {@inheritdoc}
332
     */
333 2
    public function getRoot($scope = null): array
334
    {
335 2
        $result = $this->getRoots($scope);
336
337 2
        return ($result) ? $result[0] : array();
338
    }
339
340
    /**
341
     * {@inheritdoc}
342
     */
343 2
    public function getNode($nodeId): ?array
344
    {
345 2
        $options = $this->getOptions();
346
347 2
        $nodeId = (int) $nodeId;
348
349 2
        $dbAdapter = $this->getDbAdapter();
350
351 2
        $select = $this->getDefaultDbSelect()
352 2
            ->where($options->getIdColumnName(true).' = ?', $nodeId);
353
354 2
        $row = $dbAdapter->fetchRow($select);
355
356 2
        return $row ? $row : null;
357
    }
358
359
    /**
360
     * {@inheritdoc}
361
     */
362 19
    public function getNodeInfo($nodeId): ?NodeInfo
363
    {
364 19
        $options = $this->getOptions();
365
366 19
        $nodeId = (int) $nodeId;
367
368 19
        $dbAdapter = $this->getDbAdapter();
369
370 19
        $select = $this->getBlankDbSelect()
371 19
            ->where($options->getIdColumnName(true).' = ?', $nodeId);
372
373 19
        $row = $dbAdapter->fetchRow($select);
374
375 19
        $data = $row ? $row : null;
376
377 19
        $result = ($data) ? $this->_buildNodeInfoObject($data) : null;
378
379 19
        return $result;
380
    }
381
382
    /**
383
     * {@inheritdoc}
384
     */
385 4
    public function getChildrenNodeInfo($parentNodeId): array
386
    {
387 4
        $dbAdapter = $this->getDbAdapter();
388 4
        $options = $this->getOptions();
389
390
        $columns = array(
391 4
            $options->getIdColumnName(),
392 4
            $options->getLeftColumnName(),
393 4
            $options->getRightColumnName(),
394 4
            $options->getParentIdColumnName(),
395 4
            $options->getLevelColumnName(),
396
        );
397
398 4
        if ($options->getScopeColumnName()) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $options->getScopeColumnName() of type string|null is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
399 2
            $columns[] = $options->getScopeColumnName();
400
        }
401
402 4
        $select = $this->getBlankDbSelect();
403 4
        $select->reset(\Zend_Db_Select::COLUMNS);
404 4
        $select->columns($columns);
405 4
        $select->order($options->getLeftColumnName(true));
406 4
        $select->where($options->getParentIdColumnName(true).' = ?', $parentNodeId);
407
408 4
        $data = $dbAdapter->fetchAll($select);
409
410 4
        $result = array();
411
412 4
        foreach ($data as $nodeData) {
413 3
            $result[] = $this->_buildNodeInfoObject($nodeData);
414
        }
415
416 4
        return $result;
417
    }
418
419
    /**
420
     * {@inheritdoc}
421
     */
422 2
    public function updateNodeMetadata(NodeInfo $nodeInfo): void
423
    {
424 2
        $dbAdapter = $this->getDbAdapter();
425 2
        $options = $this->getOptions();
426
427
        $bind = array(
428 2
            $options->getRightColumnName() => $nodeInfo->getRight(),
429 2
            $options->getLeftColumnName() => $nodeInfo->getLeft(),
430 2
            $options->getLevelColumnName() => $nodeInfo->getLevel(),
431
        );
432
433
        $where = array(
434 2
            $dbAdapter->quoteIdentifier($options->getIdColumnName()).' = ?' => $nodeInfo->getId(),
435
        );
436
437 2
        $dbAdapter->update($options->getTableName(), $bind, $where);
438 2
    }
439
440
    /**
441
     * {@inheritdoc}
442
     */
443 6
    public function getAncestors($nodeId, int $startLevel = 0, int $excludeLastNLevels = 0): array
444
    {
445 6
        $options = $this->getOptions();
446
447
        // node does not exist
448 6
        if (!$nodeInfo = $this->getNodeInfo($nodeId)) {
449 1
            return array();
450
        }
451
452 5
        $dbAdapter = $this->getDbAdapter();
453
454 5
        $select = $this->getDefaultDbSelect();
455
456 5
        if ($options->getScopeColumnName()) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $options->getScopeColumnName() of type string|null is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
457 2
            $select->where($options->getScopeColumnName(true).' = ?', $nodeInfo->getScope());
458
        }
459
460 5
        $select->where(
461 5
            $dbAdapter->quoteIdentifier($options->getLeftColumnName(true)).' <= ?', $nodeInfo->getLeft()
462 5
        )->where(
463 5
            $dbAdapter->quoteIdentifier($options->getRightColumnName(true)).' >= ?', $nodeInfo->getRight()
464 5
        )->order($options->getLeftColumnName(true).' ASC');
465
466 5
        if (0 < $startLevel) {
467 2
            $select->where(
468 2
                $dbAdapter->quoteIdentifier($options->getLevelColumnName(true)).' >= ?', $startLevel
469
            );
470
        }
471
472 5
        if (0 < $excludeLastNLevels) {
473 2
            $select->where(
474 2
                $dbAdapter->quoteIdentifier($options->getLevelColumnName(true)).' <= ?', $nodeInfo->getLevel() - $excludeLastNLevels
475
            );
476
        }
477
478 5
        $result = $dbAdapter->fetchAll($select);
479
480 5
        return $result;
481
    }
482
483
    /**
484
     * {@inheritdoc}
485
     */
486 9
    public function getDescendants($nodeId, int $startLevel = 0, ?int $levels = null, $excludeBranch = null): array
487
    {
488 9
        $options = $this->getOptions();
489
490 9
        if (!$nodeInfo = $this->getNodeInfo($nodeId)) {
491 1
            return array();
492
        }
493
494 8
        $dbAdapter = $this->getDbAdapter();
495 8
        $select = $this->getDefaultDbSelect();
496 8
        $select->order($options->getLeftColumnName(true).' ASC');
497
498 8
        if ($options->getScopeColumnName()) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $options->getScopeColumnName() of type string|null is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
499 3
            $select->where($options->getScopeColumnName(true).' = ?', $nodeInfo->getScope());
500
        }
501
502 8
        if (0 != $startLevel) {
503 3
            $level = $nodeInfo->getLevel() + $startLevel;
504 3
            $select->where(
505 3
                $dbAdapter->quoteIdentifier($options->getLevelColumnName(true)).' >= ?', $level
506
            );
507
        }
508
509 8
        if (null != $levels) {
0 ignored issues
show
Bug Best Practice introduced by
It seems like you are loosely comparing $levels of type null|integer against null; this is ambiguous if the integer can be zero. Consider using a strict comparison !== instead.
Loading history...
510 2
            $endLevel = $nodeInfo->getLevel() + $startLevel + abs($levels);
511 2
            $select->where(
512 2
                $dbAdapter->quoteIdentifier($options->getLevelColumnName(true)).' < ?', $endLevel
513
            );
514
        }
515
516 8
        if (null != $excludeBranch && null != ($excludeNodeInfo = $this->getNodeInfo($excludeBranch))) {
517 2
            $where = sprintf(
518 2
                '(%s OR %s) AND (%s OR %s)',
519 2
                $this->getWhereBetween($options->getLeftColumnName(true), $nodeInfo->getLeft(), $excludeNodeInfo->getLeft() - 1),
520 2
                $this->getWhereBetween($options->getLeftColumnName(true),
521 2
                    $excludeNodeInfo->getRight() + 1, $nodeInfo->getRight()),
522 2
                $this->getWhereBetween($options->getRightColumnName(true),
523 2
                    $excludeNodeInfo->getRight() + 1, $nodeInfo->getRight()),
524 2
                $this->getWhereBetween($options->getRightColumnName(true),
525 2
                    $nodeInfo->getLeft(), $excludeNodeInfo->getLeft() - 1)
526
            );
527 2
            $select->where($where);
528
        } else {
529 6
            $select->where(
530 6
                $dbAdapter->quoteIdentifier($options->getLeftColumnName(true)).' >= ?', $nodeInfo->getLeft()
531
            );
532 6
            $select->where(
533 6
                $dbAdapter->quoteIdentifier($options->getRightColumnName(true)).' <= ?', $nodeInfo->getRight()
534
            );
535
        }
536
537 8
        $resultArray = $dbAdapter->fetchAll($select);
538
539 8
        return (0 < count($resultArray)) ? $resultArray : array();
540
    }
541
542 2
    protected function getWhereBetween($column, $first, $second)
543
    {
544 2
        $dbAdapter = $this->getDbAdapter();
545 2
        $quotedColumn = $dbAdapter->quoteIdentifier($column);
546 2
        $quotedFirst = $dbAdapter->quote($first);
547 2
        $quotedSecond = $dbAdapter->quote($second);
548
549 2
        return sprintf('(%s BETWEEN %s AND %s)', $quotedColumn, $quotedFirst, $quotedSecond);
550
    }
551
}
552