Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit a4bf66a

Browse files
committed
Merge branch 'develop'
2 parents 0dd4f0c + 53fcd5f commit a4bf66a

File tree

7 files changed

+497
-9
lines changed

7 files changed

+497
-9
lines changed

CHANGELOG.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,30 @@
22

33
All notable changes to this project will be documented in this file, in reverse chronological order by release.
44

5+
## 2.11.0 - TBD
6+
7+
### Added
8+
9+
- [#336](https://github.com/zendframework/zend-db/pull/336) adds `InsertIgnore` class for "INSERT IGNORE" usage (usable in `MySQL` platform).
10+
11+
- [#356](https://github.com/zendframework/zend-db/pull/356) adds support for `IN (NULL)` for empty value-set.
12+
13+
### Changed
14+
15+
- Nothing.
16+
17+
### Deprecated
18+
19+
- Nothing.
20+
21+
### Removed
22+
23+
- Nothing.
24+
25+
### Fixed
26+
27+
- [#146](https://github.com/zendframework/zend-db/pull/146) fixes setting correct value for `lastInsertValue` pre-insert in `SequenceFeature`.
28+
529
## 2.10.2 - TBD
630

731
### Added
@@ -26,8 +50,6 @@ All notable changes to this project will be documented in this file, in reverse
2650

2751
## 2.10.1 - 2019-12-31
2852

29-
### Added
30-
3153
- Nothing.
3254

3355
### Changed

src/Sql/InsertIgnore.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
/**
3+
* @see https://github.com/zendframework/zend-db for the canonical source repository
4+
* @copyright Copyright (c) 2019 Zend Technologies USA Inc. (https://www.zend.com)
5+
* @license https://github.com/zendframework/zend-db/blob/master/LICENSE.md New BSD License
6+
*/
7+
8+
namespace Zend\Db\Sql;
9+
10+
class InsertIgnore extends Insert
11+
{
12+
/**
13+
* @var array Specification array
14+
*/
15+
protected $specifications = [
16+
self::SPECIFICATION_INSERT => 'INSERT IGNORE INTO %1$s (%2$s) VALUES (%3$s)',
17+
self::SPECIFICATION_SELECT => 'INSERT IGNORE INTO %1$s %2$s %3$s',
18+
];
19+
}

src/Sql/Predicate/In.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,13 @@ public function getExpressionData()
125125
}
126126
$countValues = count($values);
127127
$valuePlaceholders = $countValues > 0 ? array_fill(0, $countValues, '%s') : [];
128+
$inValueList = implode(', ', $valuePlaceholders);
129+
if ('' === $inValueList) {
130+
$inValueList = 'NULL';
131+
}
128132
$specification = vsprintf(
129133
$this->specification,
130-
[$identifierSpecFragment, '(' . implode(', ', $valuePlaceholders) . ')']
134+
[$identifierSpecFragment, '(' . $inValueList . ')']
131135
);
132136
}
133137

src/TableGateway/Feature/SequenceFeature.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ public function __construct($primaryKeyField, $sequenceName)
4747
*/
4848
public function preInsert(Insert $insert)
4949
{
50+
$this->tableGateway->lastInsertValue = $this->lastSequenceId();
51+
5052
$columns = $insert->getRawState('columns');
5153
$values = $insert->getRawState('values');
5254
$key = array_search($this->primaryKeyField, $columns);
@@ -70,9 +72,7 @@ public function preInsert(Insert $insert)
7072
*/
7173
public function postInsert(StatementInterface $statement, ResultInterface $result)
7274
{
73-
if ($this->sequenceValue !== null) {
74-
$this->tableGateway->lastInsertValue = $this->sequenceValue;
75-
}
75+
$this->tableGateway->lastInsertValue = $this->sequenceValue;
7676
}
7777

7878
/**

0 commit comments

Comments
 (0)