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

Model #2923

Closed
nabadao opened this issue May 4, 2020 · 6 comments
Closed

Model #2923

nabadao opened this issue May 4, 2020 · 6 comments
Labels
bug Verified issues on the current code behavior or pull requests that will fix them

Comments

@nabadao
Copy link

nabadao commented May 4, 2020

Direction
We use github issues to track bugs, not for support.
If you have a support question, or a feature request, raise these as threads on our
forum.

Describe the bug
Why does the model findall() return null, onlydeleted() - > findall() return all data instead of soft deleted data

CodeIgniter 4 version
Which version 4.03.

Affected module(s)
Which package or class is the bug in, if known.

Expected behavior, and steps to reproduce if appropriate
image
image
image
image
image
{"method":"CLI","route":"conf/getConfDeleted","handler":"\App\Controllers\Conf::getConfDeleted"},{"method":"CLI","route":"conf/delConf","handler":"\App\Controllers\Conf::delConf"}
Context

  • OS: Linux VM_21_239_centos 3.10.0-693.el7.x86_64 Initial license #1 SMP Tue Aug 22 21:09:27 UTC 2017 x86_64
  • Web server 2.4.0
  • PHP Version 7.3.16
@nabadao nabadao added the bug Verified issues on the current code behavior or pull requests that will fix them label May 4, 2020
@jlamim
Copy link
Contributor

jlamim commented May 4, 2020

Change the value of $useTimestamps to true and check if you are going to save the information for the fields that have a problem.

$useTimestamps
This boolean value determines whether the current date is automatically added to all inserts and updates. If true, will set the current time in the format specified by $dateFormat. This requires that the table have columns named ‘created_at’ and ‘updated_at’ in the appropriate data type.

@nabadao
Copy link
Author

nabadao commented May 4, 2020

更改 的值,并检查是否要为有问题的字段保存信息。$useTimestamps`` true

$useTimestamps此布尔值确定当前日期是否自动添加到所有插入和更新中。如果为 true,则以 $dateFormat 指定的格式设置当前时间。这要求表在适当的数据类型中具有名为"created_at"和"updated_at"的列。

Thank you very much for your answer. There are created at and updated at and deleted at in the database table, and $usetimestamps is also set to true, but you still don't get the desired result. For now, you can only use this method instead: $this - > confmodel - > where ('deleted at! = ', 0) - > get() - > getresultarray(); and $this - > confmodel - > where ('deleted at', 0)->get()->getResultArray();

image

image

@nyufeng
Copy link
Contributor

nyufeng commented May 6, 2020

CI4是通过 deleted_at 是不是 NULL 来判断的, 0会被认为是已经删除了,
你应该通过设置 $useTimestamps 设置为 true 来自动更新 created_at, updated_at, deleted_at,而不是自己赋值
另外注意到你的日期都是2020但是你在数据库中配置了(int) 11,你可以设置 $dateFormatint

CI4 use deleted_at IS NULL judgment the column data is delete. 0 is not null. so , the column is deleted.
you should set $useTimestamps is true. system can auto set created_at, updated_at, deleted_at
if you want use int(11) save timestamps, you muse set $dateFormat is int

@nyufeng
Copy link
Contributor

nyufeng commented May 6, 2020

你的数据库相应字 默认应该设置为NULL
in database, created_at, updated_at, deleted_at muse set Allow NULL and DEFAUILT VALUE IS NULL

@nabadao
Copy link
Author

nabadao commented May 6, 2020

CI4是通过 deleted_at 是不是 NULL 来判断的, 会被认为是已经删除了,
你应该通过设置 设置为 true 来自动更新 , , ,而不是自己赋值
另外注意到你的日期都是2020但是你在数据库中配置了(int) 11,你可以设置 为 0``$useTimestamps``created_at``updated_at``deleted_at``$dateFormat``int

CI4 use IS NULL judgment the column data is delete. is not null. so , the column is deleted.
you should set is true. system can auto set , ,
if you want use int(11) save timestamps, you muse set is deleted_at``0``$useTimestamps``created_at``updated_at``deleted_at``$dateFormat``int

好的,谢谢,我设置为 int 是为了存时间戳,可能是我把哪里设置错误了,框架执行的时候存储成为2020了

好的,谢谢,我设置为 int 是为了存时间戳,可能是我把哪里设置错误了,框架执行的时候存储成为2020了
OK, thank you. I set int to save timestamps. Maybe I set it wrong. It's 2020 when the framework executes

@nabadao
Copy link
Author

nabadao commented May 6, 2020

你的数据库相应字 默认应该设置为NULL
in database, created_at, updated_at, deleted_at muse set Allow NULL and DEFAUILT VALUE IS NULL

谢谢 按照你说的设置就可以了
hank you. Just follow your setup

@nabadao nabadao closed this as completed May 6, 2020
@michalsn michalsn changed the title `错误:Model Model Jul 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them
Projects
None yet
Development

No branches or pull requests

3 participants