Ich muss auf eine Tabelle zugreifen, indem ich auf eine andere Tabellen-ID referenziere. Auf diese Weise habe ich zuerst eine foreach-Schleife erstellt, um die ersten Tabellendaten zurückzugeben und dann ihre ID-Referenz an die zweite Tabelle. Ich habe es in meiner anderen Funktion gemacht, aber ich weiß nicht, in dieser Funktion wird mir angezeigt, dass es ein undefinierter Index ist. Hier ist mein Modell:Codeigniter mit undefiniertem Index
function retrieve_Sched($id)
{
$this->db->select('*');
$this->db->from('schedule');
$this->db->where('EmpID',$id);
$query = $this->db->get();
if($query->num_rows() == 0)
{
return false;
}
else
{
return $query->result_array();
}
}
und hier wird die Reglerfunktion:
foreach($data['result'] as $val)
{
$data['schedule'] = $this->DBmodel->retrieve_Sched($val['EmpID']);
if($data['schedule'] == false)
{
$consTimeIn = '05:30';
$consLunchOut = '10:50';
$consLunchIn = '13:00';
$consTimeOut = '17:00';
}
else
{
$consTimeIn = $data['schedule']['TimeFrom'];
$consLunchOut = $data['schedule']['LunchOut'];
$consLunchIn = $data['schedule']['LunchIn'];
$consTimeOut = $data['schedule']['TimeTo'];
}
dies ist der Fehler, die ich bekomme:
ERROR - 2016-05-23 09:57:02 --> Severity: Notice --> Undefined index: TimeFrom C:\xampp\htdocs\TMS\application\controllers\tms.php 482
ERROR - 2016-05-23 09:57:02 --> Severity: Notice --> Undefined index: LunchOut C:\xampp\htdocs\TMS\application\controllers\tms.php 483
ERROR - 2016-05-23 09:57:02 --> Severity: Notice --> Undefined index: LunchIn C:\xampp\htdocs\TMS\application\controllers\tms.php 484
ERROR - 2016-05-23 09:57:02 --> Severity: Notice --> Undefined index: TimeTo C:\xampp\htdocs\TMS\application\controllers\tms.php 485
ERROR - 2016-05-23 09:58:41 --> Severity: Notice --> Undefined index: TimeFrom C:\xampp\htdocs\TMS\application\controllers\tms.php 482
ERROR - 2016-05-23 09:58:41 --> Severity: Notice --> Undefined index: LunchOut C:\xampp\htdocs\TMS\application\controllers\tms.php 483
ERROR - 2016-05-23 09:58:41 --> Severity: Notice --> Undefined index: LunchIn C:\xampp\htdocs\TMS\application\controllers\tms.php 484
ERROR - 2016-05-23 09:58:41 --> Severity: Notice --> Undefined index: TimeTo C:\xampp\htdocs\TMS\application\controllers\tms.php 485
können Sie $ Daten var_dump [ 'Zeitplan'] kurz vor der Linie 482? –
print_r ($ data ['schedule']); sterben; vorher if condition..es könnte ein falscher Schlüssel sein oder Sie müssen "->" benutzen, um auf spezifischen Schlüssel zuzugreifen – Kunal
I var_dump und print_r und es enthält Daten. Ich habe bereits versucht, was Kunal vorgeschlagen, aber ich habe versucht, Eigentum von Nicht-Objekt Fehler zu bekommen ... – SilverRay