0

enter image description hereI make a one function to fetch the data from database in php.I used the return value of another function for select the id from the database.But when i store worker id into array i get the error "Trying to get property of non-object" like this.What i do?I wan to store match id according to query into one array.

 public function getWorkers()
    {
        $db = JFactory::getDBO();
        $orderid=$this->getTodayOrder();
        $workersId=array();
        foreach($orderid as $workers1)
        {

            $query2 = "SELECT * FROM #__orderassignment WHERE orderid='".$workers1."'";
            $db->setQuery($query2);
            $result1 = $db->loadObjectList();
            $workersId[]=$workers1->workers;
        }
         return $workersId;
    } 

1 Answers1

1

if array is given then you need to access it like this

$workersId[]=$workers1['workers'];
Exprator
  • 26,992
  • 6
  • 47
  • 59