Building web API (1 Viewer)

jon92

New Member
In need of some help building a website API. I'm trying to build a website API for a film review website and when testing the API in apigee console it's not getting the data from the MySQL tables I have already created.

Anyone got any ideas?
 

Nick

Administrator
When you say api do you mean so other people can access them?

Do you get any errors?
 

Bagsy

New Member
Might also be worth using Firefox with the Firebug Extension. I use the 'Console' mode on firebug at work, it's great for drilling down into errors in greater detail.

Just run firebug and recreate the issue with the console running.
 

jon92

New Member
this is my code ive been using

<?php
require(APPPATH.'libraries/REST_Controller.php');


class Test extends REST_Controller {

function simpletest_get() {
$data->name = 'HELLO';
$data->university = 'coventry';
$this->response($data, 200);
}


function film_get() {
$this->load->database();
$sql = 'SELECT * FROM films;';
$query = $this->db->query($sql);
$data = $query->result();

$this->response($data, 200);
}

function films_get($film_id) {
$this->load->database();
$sql = 'SELECT * FROM films WHERE code = "'.$films_id.'";';
$query = $this->db->query($sql);
$data = $query->row();

$this->response($data, 200);
}
}
 

jon92

New Member
just sorted it now changed "where code" was to "where id" and on line 23 changed function films to just function film and now it lists the film in my database.

thanks for peoples help may need more in a few minutes
 

Bagsy

New Member
Just a tip with regards to SQL statements (not sure whether you do this already). When I'm writing apps that use some SQL scripting, I normally build/test my scripts in the SQL client (In my case MS SQL Management Studio). This is because I can then see the results/ errors of the script from the native client.
 

jon92

New Member
Just a tip with regards to SQL statements (not sure whether you do this already). When I'm writing apps that use some SQL scripting, I normally build/test my scripts in the SQL client (In my case MS SQL Management Studio). This is because I can then see the results/ errors of the script from the native client.

Never used that before might give it a try in the future. Need to get my users table linked now.
 

Users who are viewing this thread

Top