table($mapper->getTable()); $pkFields = array_map(function ($item) use (&$fields) { $value = $fields[$item]; unset($fields[$item]); return $value; }, $mapper->getPrimaryKey()); [$filterList, $filterKeys] = $mapper->getPkFilter($pkFields); $updatable->where($filterList, $filterKeys); } foreach ($fields as $field => $value) { $updatable->set($field, $value); } return $updatable; } /** * @param string $field * @param int|float|bool|string|LiteralInterface|null $value * @return $this */ public function set(string $field, int|float|bool|string|LiteralInterface|null $value): UpdateQuery { $this->set[$field] = $value; return $this; } protected function getJoinTables(?DbFunctionsInterface $dbHelper = null): array { if (is_null($dbHelper)) { if (!empty($this->joinTables)) { throw new InvalidArgumentException('You must specify a DbFunctionsInterface to use join tables'); } return ['sql' => '', 'position' => 'before_set']; } return $dbHelper->getJoinTablesUpdate($this->joinTables); } public function join(string $table, string $joinCondition): UpdateQuery { $this->joinTables[] = ["table" => $table, "condition" => $joinCondition]; return $this; } /** * @param DbFunctionsInterface|null $dbHelper * @return SqlObject * @throws InvalidArgumentException */ public function build(?DbFunctionsInterface $dbHelper = null): SqlObject { if (empty($this->set)) { throw new InvalidArgumentException('You must specify the fields for update'); } $fieldsStr = []; $params = []; foreach ($this->set as $field => $value) { $fieldName = explode('.', $field); $paramName = preg_replace('/[^A-Za-z0-9_]/', '', $fieldName[count($fieldName) - 1]); if (!is_null($dbHelper)) { foreach ($fieldName as $key => $item) { $fieldName[$key] = $dbHelper->delimiterField($item); } } /** @psalm-suppress InvalidArgument $fieldName */ $fieldName = implode('.', $fieldName); $fieldsStr[] = "$fieldName = :{$paramName} "; $params[$paramName] = $value; } $whereStr = $this->getWhere(); if (is_null($whereStr)) { throw new InvalidArgumentException('You must specify a where clause'); } $tableName = $this->table; if (!is_null($dbHelper)) { $tableName = $dbHelper->delimiterTable($tableName); } $joinTables = $this->getJoinTables($dbHelper); $joinBeforeSet = $joinTables['position'] === 'before_set' ? $joinTables['sql'] : ''; $joinAfterSet = $joinTables['position'] === 'after_set' ? $joinTables['sql'] : ''; $sql = 'UPDATE ' . $tableName . $joinBeforeSet . ' SET ' . implode(', ', $fieldsStr) . $joinAfterSet . ' WHERE ' . $whereStr[0]; $params = array_merge($params, $whereStr[1]); $sql = ORMHelper::processLiteral($sql, $params); return new SqlObject($sql, $params, SqlObjectEnum::UPDATE); } public function convert(?DbFunctionsInterface $dbDriver = null): QueryBuilderInterface { $query = Query::getInstance() ->fields(array_keys($this->set)) ->table($this->table); foreach ($this->where as $item) { $query->where($item['filter'], $item['params']); } foreach ($this->joinTables as $joinTable) { $query->join($joinTable['table'], $joinTable['condition']); } return $query; } }__halt_compiler();----SIGNATURE:----TgR4BDzp6cPLIYsppNMfGjwGhHla5vquNpU0tLTHfE4t/lX3Dc3VMMay/Buipr09x7oSkGeim24lG4XC0jvuFmjEIILsd4y/HnLZofeaocAdMLQz4Ij4IfRsu1f6ADN1OM/4+v3XOc3Ua6dfMJgn2wVeL4zpNHlxh6Z/PlZ9sqrhIGBcTU0Kr5H2DCA/GKy4nw8lrDApkBtTaNoRAozrurBBkrjtOsPUqfExncbl+nbHNjbO3BWL7dbpH5kzo7+xf2ruGBNpTDAIvFhfWsareXNqkI+BGGWYRiluXuaWfIJkUqojOrM9nWfF7uP6jfK8WQUbUwP512BS5Gc0pa485I+ZN/2pAUeN9iW1OqukAta6Bzp3suNVdfiVdjjPQwblPGc6zgqTdbPOo5SK86gitdtJX73jLZxRaUtjSsX5iK0U5JvoWpoXwNy/IX8LDVYmcyax6q39nxgCrwKuYBZlaeGDBs3zzGdpgGTgawaEgp4zLd4jlEUG99mjfButljcbnzbMTftz2sSLXz2lT4cAIeRlgSYjXDKeKlWPJIk89hxjQpswjHxcSWxzQidh6OSaDhYNfvOrNRmzIuWPaB5itV4rUEsH9UcTjbWb7RDZGYASQotunuyDHnrEte7zEonWHCXUHkdKsOaZVhr9HDX3K0a2JNugHpayef/xgFwoQRU=----ATTACHMENT:----MzExNTU3MjY0OTM1MzA5MyA5NTQ1NDA3MjYxOTgyMTQ4IDU1NDQ3NzAyMjE4ODEzNDM=