Fetch multiple result from database in codeigniter 4

Shop Forums Codeigniter Discussion Working with codeigniter 4 database Fetch multiple result from database in codeigniter 4

Viewing 0 reply threads
  • Author
    Posts
    • #7187
      Projects Plaza
      Participant

      With the help of following query we can fetch multiple data from database.

      Object Version

      $query = $db->query('SELECT * my_table');
      $results = $query->getResult();
      
      foreach ($results as $row)
      {
              echo $row->id;
              echo $row->title;
              echo $row->name;
      }

      Array Version

      $query = $db->query('SELECT * my_table');
      $results = $query->getResultArray();
      
      foreach ($results as $row)
      {
              echo $row['id'];
              echo $row['title'];
              echo $row['name'];
      }
Viewing 0 reply threads
  • You must be logged in to reply to this topic.