使用PHP检查MYSQL上的TIME字段

时间:2022-01-25 07:46:22

I am going utterly insane, and need someone to put my out of my misery

我完全疯了,需要有人来摆脱我的痛苦

I have a field in my MYSQL called 'overide_start_time' which is a standard time type.

我的MYSQL中有一个名为'overide_start_time'的字段,它是标准的时间类型。

I am trying to test whether that field is empty (the field is not defined as null as it can be filled, and then deleted if the time is removed)

我正在尝试测试该字段是否为空(该字段未定义为null,因为它可以填充,然​​后如果时间被删除则删除)

I have tried

我试过了

empty()
is_null()
!isset()

I have tried logical operators between the statements, but in every single instance the check thinks that there is something in that field, when I have confirmed 100% that field has nothing in it (it is empty, not null)

我已经在语句之间尝试了逻辑运算符,但是在每个单独的实例中,检查认为该字段中存在某些内容,当我确认100%该字段中没有任何内容时(它为空,不为空)

My exact line of code is

我的确切代码是

<?php if (is_null($row->override_end_time) || empty($row->override_end_time) || !isset($row->override_end_time)) { ?>

A - do something if the value is not set, null or empty

<?php } or { ?>

B - do something if it has something set

<?php }; ?>

the field is not filled and in every single instance the if statement continues with B as though it IS set with a value

字段未填充,并且在每个实例中,if语句继续使用B,就像它使用值设置一样

EDIT : When I do a var_dump($row->override_end_time) the output to the screen is NULL

编辑:当我执行var_dump($ row-> override_end_time)时,屏幕输出为NULL

1 个解决方案

#1


OK Feeling a little bit stupid for trying to be too clever.

好的尝试太聪明感觉有点愚蠢。

All I needed was

我所需要的只是

<?php if ($row->override_start_time == NULL) {...}

Thanks to xcloudx for the var_dump suggestion

感谢xcloudx提供的var_dump建议

#1


OK Feeling a little bit stupid for trying to be too clever.

好的尝试太聪明感觉有点愚蠢。

All I needed was

我所需要的只是

<?php if ($row->override_start_time == NULL) {...}

Thanks to xcloudx for the var_dump suggestion

感谢xcloudx提供的var_dump建议