Skip to content

Commit

Permalink
Use doctrine for database statements
Browse files Browse the repository at this point in the history
  • Loading branch information
digedag committed Sep 28, 2024
1 parent 6251065 commit 1c1667e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
1 change: 0 additions & 1 deletion Classes/Database/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,6 @@ public function doUpdate($tablename, $where, $values, $arr = [], $noQuoteFields
return $affectedRows;
}


// if ($debug || !empty($arr['sqlonly'])) {
// $sql = $database->UPDATEquery($tablename, $where, $values, $noQuoteFields);
// if (!empty($arr['sqlonly'])) {
Expand Down
3 changes: 1 addition & 2 deletions Classes/Database/QueryBuilderFacade.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function doUpdate(From $from, $arr): ?QueryBuilder

$queryBuilder = $this->getConnectionPool()->getQueryBuilderForTable($tableName);
$queryBuilder->update($tableName, $tableAlias != $tableName ? $tableAlias : null);
foreach($values as $col => $value) {
foreach ($values as $col => $value) {
$queryBuilder->set($col, $value);
}

Expand Down Expand Up @@ -104,7 +104,6 @@ public function doUpdate(From $from, $arr): ?QueryBuilder
return $queryBuilder;
}


public function doDelete(From $from, $arr): ?QueryBuilder
{
if (!empty($from->getClause()) || $from->isComplexTable()) {
Expand Down
3 changes: 1 addition & 2 deletions Classes/Domain/Repository/PersistenceRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,7 @@ private function persistUpdate(
) {
$model = $transport->getModel();


$where = function (QueryBuilder $qb) use($model) {
$where = function (QueryBuilder $qb) use ($model) {
$qb->where('uid = :uid')
->setParameter('uid', $model->getProperty('uid'));
};
Expand Down
11 changes: 9 additions & 2 deletions tests/Classes/Domain/Repository/PersistenceRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/***************************************************************
* Copyright notice
*
* (c) 2016-2021 René Nitzsche <[email protected]>
* (c) 2016-2024 René Nitzsche <[email protected]>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
Expand All @@ -25,6 +25,7 @@
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

use Closure;
use stdClass;
use Sys25\RnBase\Database\Connection;
use Sys25\RnBase\Domain\Model\BaseModel;
Expand Down Expand Up @@ -213,7 +214,13 @@ public function testPersistExistingModel()
->method('doUpdate')
->with(
$this->equalTo('tt_content'),
$this->equalTo('uid=7'),
$this->callback(
function ($where) {
self::assertInstanceOf(Closure::class, $where);

return true;
}
),
$this->callback(
function ($data) {
self::assertTrue(is_array($data));
Expand Down

0 comments on commit 1c1667e

Please sign in to comment.