如何在yii标准中使用isset

时间:2013-09-19 09:33:05

标签: php yii

无论如何在yii 标准中使用isset?

我有两个名为设备和供应的表..它们几乎相同,只是设备有一个名为stock_no的字段。现在我有一个搜索功能来显示设备或供应记录,具体取决于下拉列表。

基本上我想要的是使用isset到检查如果* stack_no * 存在来证明来自设备

    if($this->itemType=="Equipment"){
            $criteria->isset('stock_no', true ); // what may be the correct way to check if this column is existing? 
    }

    if($this->itemType=="Supply"){

    }

1 个答案:

答案 0 :(得分:0)

您可以执行此查询。

SELECT count(*) exist FROM information_schema.COLUMNS 
                      WHERE TABLE_SCHEMA = 'yourSchema' 
                      AND TABLE_NAME = 'yourTable' 
                      AND COLUMN_NAME = 'stock_no'

如果在指定的表上存在此列,则返回1或0。