NULL作为codeignitier活动记录选择内的列?

时间:2015-12-01 18:00:59

标签: php mysql codeigniter

当我尝试这个时:

 $this->db->select('`LeagueCode`,`DateT`,`HomeTeam`,`AwayTeam`,NULL as `FTHG`,null as `FTAG`,null as `FTR`,null as `HTHG`,null as `HTAG`,null as `HTR`,null as `Referee`,null as `HS`,null as `AS`,null as `HST`,null as `AST`,null as `HF`,null as `AF`,null as `HC`,null as `AC`,null as `HY`,null as `AY`,null as `HR`,null as `AR`,null as `B365H`,null as `B365D`,null as `B365A`,null as `BSH`,null as `BSD`,null as `BSA`,null as `BWH`,
    null as `BWD`,null as `BWA`,null as `GBH`,null as `GBD`,null as `GBA`,null as `IWH`,null as `IWD`,null as `IWA`,null as `LBH`,null as `LBD`,null as `LBA`,null as `PSH`,null as `PSD`,null as `PSA`,null as `SOH`,null as `SOD`,null as `SOA`,null as `SBH`,
    null as `SBD`,null as `SBA`,null as `SJH`,null as `SJD`,null as `SJA`,null as `SYH`,null as `SYD`,null as `SYA`,null as `VCH`,null as `VCD`,null as `VCA`,null as `WHH`,null as `WHD`,null as `WHA`,null as `Bb1X2`,null as `BbMxH`,null as `BbAvH`,null as `BbMxD`,null as `BbAvD`,null as `BbMxA`,null as `BbAvA`,null as `BbOU`,null as `BbMxM25`,null as `BbAvM25`,null as `BbMxS25`,null as `BbAvS25`,null as `BbAH`,null as `BbAHh`,null as `BbMxAHH`,
null as `BbAvAHH`,null as `BbMxAHA`,null as `BbAvAHA`,null as `GBM25`,null as `GBS25`,null as `GBAHH`,null as `GBAHA`,null as `GBAH`,null as `B365M25`,null as `B365S25`,null as `B365AHH`,null as `B365AHA`,
    null as `B365AH`,null as `LBAHH`,null as `LBAHA`,null as `LBAH`,null as `MxH`,null as `MxD`,null as `MxA`,null as `MxO25`,null as `MxU25`,null as `MxAHH`,null as `MxAHA`,null as `AvH`,null as `AvD`,null as `AvA`,null as `AvO25`,null as `AvU25`,null as `AvAHH`,null as `AvAHA`,"1516" as `Season`');

我得到了

  

'字段列表'中的未知列'NULL'

我看到它将null转换为

 `null`

所以最后它看起来像这样:

SELECT `LeagueCode`, `DateT`, `HomeTeam`, `AwayTeam`, `NULL` as `FTHG`, `null` as `FTAG`, `null` as `FTR`, `null` as `HTHG`, `null` as `HTAG`, `null` as `HTR`, `null` as `Referee`, `null` as `HS`, `null` as `AS`, `null` as `HST`, `null` as `AST`, `null` as `HF`, `null` as `AF`, `null` as `HC`, `null` as `AC`, `null` as `HY`, `null` as `AY`, `null` as `HR`, `null` as `AR`, `null` as `B365H`, `null` as `B365D`, `null` as `B365A`, `null` as `BSH`, `null` as `BSD`, `null` as `BSA`, `null` as `BWH`, `null` as `BWD`, `null` as `BWA`, `null` as `GBH`, `null` as `GBD`, `null` as `GBA`, `null` as `IWH`, `null` as `IWD`, `null` as `IWA`, `null` as `LBH`, `null` as `LBD`, `null` as `LBA`, `null` as `PSH`, `null` as `PSD`, `null` as `PSA`, `null` as `SOH`, `null` as `SOD`, `null` as `SOA`, `null` as `SBH`, `null` as `SBD`, `null` as `SBA`, `null` as `SJH`, `null` as `SJD`, `null` as `SJA`, `null` as `SYH`, `null` as `SYD`, `null` as `SYA`, `null` as `VCH`, `null` as `VCD`, `null` as `VCA`, `null` as `WHH`, `null` as `WHD`, `null` as `WHA`, `null` as `Bb1X2`, `null` as `BbMxH`, `null` as `BbAvH`, `null` as `BbMxD`, `null` as `BbAvD`, `null` as `BbMxA`, `null` as `BbAvA`, `null` as `BbOU`, `null` as `BbMxM25`, `null` as `BbAvM25`, `null` as `BbMxS25`, `null` as `BbAvS25`, `null` as `BbAH`, `null` as `BbAHh`, `null` as `BbMxAHH`, `null` as `BbAvAHH`, `null` as `BbMxAHA`, `null` as `BbAvAHA`, `null` as `GBM25`, `null` as `GBS25`, `null` as `GBAHH`, `null` as `GBAHA`, `null` as `GBAH`, `null` as `B365M25`, `null` as `B365S25`, `null` as `B365AHH`, `null` as `B365AHA`, `null` as `B365AH`, `null` as `LBAHH`, `null` as `LBAHA`, `null` as `LBAH`, `null` as `MxH`, `null` as `MxD`, `null` as `MxA`, `null` as `MxO25`, `null` as `MxU25`, `null` as `MxAHH`, `null` as `MxAHA`, `null` as `AvH`, `null` as `AvD`, `null` as `AvA`, `null` as `AvO25`, `null` as `AvU25`, `null` as `AvAHH`, `null` as `AvAHA`, "1516" as `Season` FROM `odds` WHERE `LeagueCode` = 'SC0' ORDER BY `DateT`

我想从NULL中删除此引号,我该怎么做? 我需要使用NULL作为列,因为我将使用此查询进行联合。

2 个答案:

答案 0 :(得分:0)

我认为使用null值没有问题,但可能是你的框架问题,所以如果你使用codeigniter你可以用db->查询替换db-> select()('在这里写你的完整查询' )

答案 1 :(得分:0)

使用第二个参数

$this->db->select('...',false);