php - codeigniter restful web service + database query -


forgive me upcoming question, lol. (im terribly new @ this)

i have read tutorial .

i've set auto connect database editing autoload.php file.

i'm creating own controller called dsapi.php(code below), want ad_get() function retrieve data simple database can use in android app have developed.

i had @ guidelines page and tried write im pretty clueless can see. close want?

class dsapi extends rest_controller {      function ad_get()     {         **$query = $this->db->query('select index, title, detailed ads');          foreach ($query->result_array() $row)         {             echo $row['index'];             echo $row['title'];             echo $row['detailed'];         }          $this->response($query, 200);**     }      function ad_put()     {         // create new user , respond status/errors     }      function ad_post()     {         // update existing user , respond status/errors     }      function ad_delete()     {         // delete user , respond status/errors     } } 

video tutorial description of model , code example

 class blogmodel extends ci_model   {  var $title   = '';  var $content = '';  var $date    = '';   function __construct()  {      // call model constructor      parent::__construct();  }   function get_last_ten_entries()  {      $query = $this->db->get('entries', 10);      return $query->result();  }   function insert_entry()  {      $this->title   = $_post['title']; // please read below note      $this->content = $_post['content'];      $this->date    = time();       $this->db->insert('entries', $this);  }   function update_entry()  {      $this->title   = $_post['title'];      $this->content = $_post['content'];      $this->date    = time();       $this->db->update('entries', $this, array('id' => $_post['id']));  }} 

Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -