Basic Code Igniter Model


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?php
  2. class Helloworld_model extends Model {
  3.  
  4. function Helloworld_model()
  5. {
  6. // Call the Model constructor
  7. parent::Model();
  8. }
  9.  
  10. function getData()
  11. {
  12. //Query the data table for every record and row
  13. $query = $this->db->get('data');
  14.  
  15. if ($query->num_rows() > 0)
  16. {
  17. //show_error('Database is empty!');
  18. }else{
  19. return $query->result();
  20. }
  21. }
  22.  
  23. }
  24. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.