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:----K5D4dGhoYNtJNVm0iksSC667H0ySdwYVNe4wYOc0rE6xAbt7VblMeX54d7jvoTsQz+XRMI6mDiAoXXA76OJmUv/OsfH/t0O4Myr0NFGGe+yMyQqHP5+M8RUqhRR3nbHfupapcDOOsJxcFdPMNfkqiBv3gAQsoGOfusNdKwgaX7Dc+YZmzQPRdc9VkkB0FQWXmq/l1f4rTzhPBGHyye0JQNfIywGuu9A9kBXEMtffveuEwuZwc9bYXQlbI9FOTNbL7tMizaFw8G319ix/qkppnpJvusSilCX8KHYHCGLJZ4bZiNo8Hv7ntPYKFavSceNe+MkgmSokzdTQwUq5DcVn9xQ0458asNsUCfdYZp1IIaFcfRtZ01qQ9hrxP1PbjvyBo+p38Iuvem5hK8YF8F0vFr3CvIxMl5BRluGNjs2S9+dlgxL7Di9/LHwe86ELE2UvkEqdLglgCZ8Js6MrhJikRHHMPsxDCBzK8OHNbCfKzX8vI/NqPGkzC6+qTOQuVBGBsv91EsFNEom1k3z0MEp/iXAc6pD6e68QN+1bcMv5FGovWxvdcuNJ2CIEKjYet6pMBfo0hsPmfvoU55ftqMeOJkFzYmRh6z5RMxF8UeIzSeI/NHjnt5LzYFVscg5vxFiP34+zdkhknrM4n0XeJzsAI+483+bhGW7Y7vBlJE/fGEA=----ATTACHMENT:----NjAxMDMwMzY1Njk3MjQzNyA5MDc3NzIwNTI1NzYzNTggMjY3NjgwNzE2Mjg0Njc0