Advertisement
mahdidham

codeigniter-model

Jan 4th, 2016
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.45 KB | None | 0 0
  1. <?php
  2. //birds_model.php (Array of Strings)
  3. class Birds_model extends CI_Model{
  4.   function get_bird($q){
  5.     $this->db->select('bird');
  6.     $this->db->like('bird', $q);
  7.     $query = $this->db->get('birds');
  8.     if($query->num_rows > 0){
  9.       foreach ($query->result_array() as $row){
  10.         $row_set[] = htmlentities(stripslashes($row['bird'])); //build an array
  11.       }
  12.       echo json_encode($row_set); //format the array into json data
  13.     }
  14.   }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement