Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.0版本,联合主键save时报错Cannot access offset of type array on array #673

Open
cs99619 opened this issue Feb 18, 2025 · 1 comment

Comments

@cs99619
Copy link

cs99619 commented Feb 18, 2025

经跟踪src/Model.php文件941行错误
将原来代码

        if ($this->key) {
            $where = [$pk => $this->key];
        } elseif (is_string($pk) && isset($this->origin[$pk])) {
            $where     = [$pk => $this->origin[$pk]];
            $this->key = $this->origin[$pk];
        } elseif (is_array($pk)) {
            foreach ($pk as $field) {
                if (isset($this->origin[$field])) {
                    $where[] = [$field, '=', $this->origin[$field]];
                }
            }
        }

修改为:

        if ($this->key) {
            if (is_array($this->key)) {
                foreach ($this->key as $field) {
                    if (isset($this->origin[$field])) {
                        $where[] = [$field, '=', $this->origin[$field]];
                    }
                }
            } else {
                $where = [$pk => $this->key];
            }
        } elseif (is_string($pk) && isset($this->origin[$pk])) {
            $where     = [$pk => $this->origin[$pk]];
            $this->key = $this->origin[$pk];
        } elseif (is_array($pk)) {
            foreach ($pk as $field) {
                if (isset($this->origin[$field])) {
                    $where[] = [$field, '=', $this->origin[$field]];
                }
            }
        }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@cs99619 and others