如何在yii标准中的addCondition中使用isset [英] how to use isset inside addCondition in yii criteria

查看:32
本文介绍了如何在yii标准中的addCondition中使用isset的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试在 addCondition 中使用 isset 来检查字段是否存在

Hi I've been trying to check if a field is existing using isset inside addCondition like this

$criteria->addCondition('isset(status_id)');

但没有运气.任何人都可以为此建议正确的语法吗?谢谢

but no luck. Can anyone suggest the right syntax for this? thanks

推荐答案

要检查变量,可以使用 isset().但是你试图做的不是正确的方法.addCondition 方法不应该执行 PHP 函数.检查文档

For checking a variable, you can use isset(). But what you are trying to do is not the correct way. The addCondition method is not supposed to execute PHP functions. Check the documentation

但是如果你想检查status_id中的值,你可以这样做 -

But If you want to check the value in status_id, tou can do like this -

$criteria->addCondition('status_id IS NOT NULL');

这篇关于如何在yii标准中的addCondition中使用isset的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆