diff --git a/CHANGELOG.md b/CHANGELOG.md index 34ad2592..75714a53 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +# Version 16.8.12 + +## Improvement + +* None + +## Bugfixes + +* Extend prepareRow() method remove not foud entities + # Version 16.8.11 ## Improvement diff --git a/src/Actions/Processors/AbstractBaseProcessor.php b/src/Actions/Processors/AbstractBaseProcessor.php index 5edae73d..f93bb676 100644 --- a/src/Actions/Processors/AbstractBaseProcessor.php +++ b/src/Actions/Processors/AbstractBaseProcessor.php @@ -178,16 +178,26 @@ protected function getPreparedStatements() * Prepare's and return's the passed row by removing the * entity status. * - * @param array $row The row to prepare + * @param array $row The row to prepare + * @param string $statement The statement string * * @return array The prepared row */ - protected function prepareRow(array $row) + protected function prepareRow(array $row, $statement = '') { // remove the entity status unset($row[EntityStatus::MEMBER_NAME]); + // Remove unused rows from statement + if (!empty($statement)) { + foreach ($row as $key => $value) { + if (!preg_match('/(:'.$key.'[^a-zA-Z_])|(:'.$key.'$)/', $statement)) { + unset($row[$key]); + } + } + } + // return the prepared row return $row; } @@ -219,7 +229,7 @@ public function execute($row, $name = null, $primaryKeyMemberName = null) try { // finally execute the prepared statement - $statement->execute($this->prepareRow($row)); + $statement->execute($this->prepareRow($row, $statement->queryString)); } catch (\PDOException $pdoe) { // initialize the SQL statement with the placeholders $sql = $statement->queryString;