codeigniter restful web service + database query

Revadietsols

New Member
Forgive me for the upcoming question, lol. (Im terribly new at this)I have read this tutorial .I've already set up the auto connect to database by editing the autoload.php file.I'm creating my own controller called dsapi.php(code below), I want the \[code\]ad_get()\[/code\] function to retrieve all the data from my simple database so I can use it in the android app that I have developed.I had a look at this guidelines page and tried to write something but im pretty clueless as you can see. Am I even close to what I want?\[code\]class dsapi extends REST_Controller { function ad_get() { **$query = $this->db->query('SELECT index, title, detailed FROM ads'); foreach ($query->result_array() as $row) { echo $row['index']; echo $row['title']; echo $row['detailed']; } $this->response($query, 200);** } function ad_put() { // create a new user and respond with a status/errors } function ad_post() { // update an existing user and respond with a status/errors } function ad_delete() { // delete a user and respond with a status/errors }}\[/code\]
 
Back
Top