I'm doing array
and I get the following error:
Fatal error: Can not use object of type CI_DB_mysqli_result as array in C: \ xampp \ htdocs \ olPrueba2 \ application \ controllers \ Admin.php on line 748 A PHP Error was encountered Severity: Error
Message: Can not use object of type CI_DB_mysqli_result as array
Filename: controllers / Admin.php
Line Number: 748
Backtrace:
The array
will have data that I get from the database, this is the method where I generate it:
public function teniurtype()
{
$postData = $this->input->post();
//$postName = json_decode(stripslashes($postData['roster_salesforcename']));
$postAdvocate = $postData['sup'];
$Date = date("Y-m-d H:i:s");
$arrayMtd = array();
$arrayAdvocates = array();
$arrayhire_date = array();
$arrayhire_date = $this->ol_model->gethire_date($postAdvocate);
$arrayAdvocates = $this->ol_model->getadvocatesSup($postAdvocate);
$sizeArrAdv = sizeof($arrayAdvocates);
$bandera = false;
$dateC = new DateTime($Date);
$monthC = $dateC->format('m');
$yearC = $dateC->format('Y');
$dayC = $dateC->format('d');
$Type3 = "T3";
$Type2 = "T2";
$Type1 = "T1";
$monthCn = (int)$monthC;
$yearCn = (int)$yearC ;
$i=0;
for ($i=0; $i < $sizeArrAdv ; $i++) {
$Yhire_date = $this->ol_model->getyearHire($arrayAdvocates[$i]["roster_salesforcename"]);
$Mhire_date = $this->ol_model->getmonthHire($arrayAdvocates[$i]["roster_salesforcename"]);
$Yhire_daten = (int)$Yhire_date;
$Mhire_daten = (int)$Mhire_date;
$u=($yearCn-$Yhire_daten)*12;
$d=$u+($monthCn-1);
$t=$d-($Mhire_daten);
$monthworked =$t;
//$monthworked = ((($yearC)-($Yhire_date))*12)+($monthC-1)-($Mhire_date);
if ($monthworked > 11){
if($monthworked >= 12 && $monthworked < 18 ){
if ($Mhire_date%2==0){
$mworked = array('advocate' => $arrayAdvocates[$i]["roster_salesforcename"], 'Hire_Date' => $arrayhire_date[$i]["roster_hire_date"], 'Tenure' => $monthworked, 'Type' => $Type3, 'Bono' => "70.000");
}else{
$mworked = array('advocate' => $arrayAdvocates[$i]["roster_salesforcename"], 'Hire_Date' => $arrayhire_date[$i]["roster_hire_date"], 'Tenure' => $monthworked, 'Type' => $Type3, 'Bono' => "80.000");
}
}elseif ($monthworked >= 18 && $monthworked < 24) {
if ($Mhire_date%2==0){
$mworked = array('advocate' => $arrayAdvocates[$i]["roster_salesforcename"], 'Hire_Date' => $arrayhire_date[$i]["roster_hire_date"], 'Tenure' => $monthworked, 'Type' => $Type3, 'Bono' => "150.000");
}else{
$mworked = array('advocate' => $arrayAdvocates[$i]["roster_salesforcename"], 'Hire_Date' => $arrayhire_date[$i]["roster_hire_date"], 'Tenure' => $monthworked, 'Type' => $Type3, 'Bono' => "150.000");
}
}elseif ($monthworked > 24) {
if ($Mhire_date%2==0){
$mworked = array('advocate' => $arrayAdvocates[$i]["roster_salesforcename"], 'Hire_Date' => $arrayhire_date[$i]["roster_hire_date"],'Tenure' => $monthworked, 'Type' => $Type3, 'Bono' => "220.000");
}else{
$mworked = array('advocate' => $arrayAdvocates[$i]["roster_salesforcename"], 'Hire_Date' => $arrayhire_date[$i]["roster_hire_date"], 'Tenure' => $monthworked, 'Type' => $Type3, 'Bono' => "230.000");
}
}
}else{
echo 'No cumple el requisito de cantidad de meses trabajados';
}
array_push($arrayMtd, $mworked);
}
echo json_encode($arrayMtd);
}