CodeIgniter Forums
How to get two different result in joined table CI4 with default ID - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: General (https://forum.codeigniter.com/forumdisplay.php?fid=1)
+--- Forum: Regional User Groups (https://forum.codeigniter.com/forumdisplay.php?fid=25)
+--- Thread: How to get two different result in joined table CI4 with default ID (/showthread.php?tid=81103)



How to get two different result in joined table CI4 with default ID - luckmoshy - 01-24-2022

Hi guys Here have joined table (accommodationtable and icons table) work fine
  I want to fetch results with different call
         
 
PHP Code:
  foreach($AccommodationModel as $listAccommodationItems){/*"1,2,3,"*/

and
PHP Code:
  foreach($AccommodationModel as $listicons){/*"1,2,3,"*/

but is not work why? I get this error  (Cannot access offset of type string on string )

I mean to get data from accommodation and icons table separately  but with one id (joined)

         
PHP Code:
  

/*This is the last view page mean to read a full articles*/
/*here not work*/
 
public function view($slug null,)
{
         $AccommodationModel = new AccommodationModel();
  $data=[
/*mult-array data--------------.......*/
    'AccommodationModel' => $AccommodationModel
    
->join('icons''icons.id =accommodationtable.accommodation_id')
    ->getAccommodationItems($slug),
];
return 
view('accommodation_view_all',$data);/*from read more */


But in customer function works in the wildcard, it is not works
PHP Code:
  


 
public function costmerFunction ()
{
    /*here it works ok*/

         $AccommodationModel = new AccommodationModel();
$data[
    'AccommodationModel' => $AccommodationModel
 
->join('icons''icons.id =accommodationtable.accommodation_id')
 ->
getAccommodationItems(),
];
return 
view('accommodation_view_all',$data);





I have directed cause of error  this function view is the last call for the page  I don't know how can I fetch data from accommodation table and icons table to get the same table joined id  because if I call table id with different id (not joined) it can't because it shows accommodation table with different rows but for icons table, it shows only the same and all data rows in every view page instead of  different rows


RE: How to get two different result in joined table CI4 with default ID - kenjis - 01-24-2022

Sorry, I don't get what you say.
Show your MVC code, if you do, someone might answer something.