top-think / top-think/think-orm

使用Model::suffix方法无效。不能添加后缀

Open
#798 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
437
Forks
188
PR merge metrics
No merged PRs in 30d

Description

thinkphp-orm: 4.0.49

代码:
ProductModel::suffix($this->lang)->field("{$field}, video_cover, video_url")->where(['status' => 1])->order("id DESC")->find();

运行报错,提示 Shop.sp_product表不存在。后缀_cn 没有添加上去。所以提示表不存在,

如果再ProductModel.php文件里使用

protected $suffix = "_cn";

这样写死就可以。

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the ProductModel.php definition and the Model::suffix call shown in the report, then reproduce the query using the provided example. Trace how the suffix reaches table resolution and verify that the generated table name includes _cn instead of reporting Shop.sp_product as missing.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.