Codeigniter连续查询创建未定义的索引

时间:2013-09-12 07:50:14

标签: php sql sql-server codeigniter

我一直遇到连续查询的问题。我不知道CodeIgniter是否与它有关。如果发生了什么,有人可以启发我吗?

鉴于


$Attendees是一组员工编号 $data是来自$ _POST的数组 $data ['quads'.trim($attendees[$i])] - 我试图获得索引为quads1234567的POST数据,其中数字是员工编号。

for($i=0; $i < count($attendees)-1; $i++){

        $data_update = array(
            'QD'.$data['quads'.trim($attendees[$i])][0].'RTE' => 3 ,
            'FTRNNG'  => 'N' ,
        );

        $this->db->where('TRNSRS', $data['series']); 
        $this->db->where('EMPNUM', trim($attendees[$i])); 
        $this->db->update('EmployeeSmartsDB', $data_update); 

        $data = array(
           'YRSEM'  => '201301' ,
           'EMPNUM' => trim($attendees[$i]) ,
           'UNTCDE' => $data['unitcode'] ,
           'TRNTYP' => $data['training_type'],
           'TRNSRS' => $data['series'] ,
           'SKLCDE' => $data['skillcde'] ,
           'ACTDTE' => '20130912' ,
           'ACTTME' => '1534' ,
           'EMPRTE' => $data['quads'.trim($attendees[$i])][1],
           'QUDRNT' => $data['quads'.trim($attendees[$i])][0],
           'RMARKS' => $data['remarks'.trim($attendees[$i])],
        );

        $this->db->insert('EmployeeLedgerDB', $data); 

    }

现在,情况是当我注释掉插入查询时,整个事情执行得很完美但是一旦我包含了插入查询,$data ['quads'.trim($attendees[$i])]的索引就没有定义,$data['series']索引也是也没有定义。

所有错误都发生在更新查询中,而不是插入查询中。我甚至尝试回显值,并且在取消注释插入查询时它们会消失。

1 个答案:

答案 0 :(得分:1)

希望有所帮助:

$insertData   = array(              #change the name of the array as $data you said is already assiged 
   'YRSEM'  => '201301' ,
   'EMPNUM' => trim($attendees[$i]) ,
   'UNTCDE' => $data['unitcode'] ,
   'TRNTYP' => $data['training_type'],
   'TRNSRS' => $data['series'] ,
   'SKLCDE' => $data['skillcde'] ,
   'ACTDTE' => '20130912' ,
   'ACTTME' => '1534' ,
   'EMPRTE' => $data['quads'.trim($attendees[$i])][1],
   'QUDRNT' => $data['quads'.trim($attendees[$i])][0],
   'RMARKS' => $data['remarks'.trim($attendees[$i])],
);

$this->db->insert_batch('EmployeeLedgerDB', $insertData);