0

所以我有这个搜索 torrent_download 的查询,torrent_download 只能是 1 或 0;

$sql_istorrenthere = $this->query("SELECT torrent_download
FROM " . DB_PREFIX . "auctions WHERE
                auction_id='" . $item_details['auction_id'] . "'"); 
if (empty($sql_istorrenthere))
{

        $display_output = GMSG_NOTORRENT;}
        else
        $display_output = GMSG_TORRENT;
}

我想要做的是if (empty($sql_istorrenthere))用类似的东西替换部分if $sql_istorrenthere == 1 then $display_output = GMSG_NOTORRENT; else $display_output = GMSG_TORRENT;

这个怎么做?

4

1 回答 1

1

您首先必须获取结果行,很难说如何因为您没有告诉我们您正在使用的框架/数据库抽象层。检查文档,您希望将结果作为数组或对象获取。

对于数组:

尝试使用 显示结果var_dump,如果成功,您将看到一个数组,其中键为torrent_download键。然后简单地与$res['torrent_download']比较1

于 2012-05-01T21:41:54.070 回答