I have two tables, files
and servers
. Here's the schema:
f_id, s_id, u_id, name, size, downloads, uploaded
s_id, name, description, disk_space, used_space, enabled
Now, I'm trying to get some information about a particular file as well as what server it's hosted on. In the files
table, this is determined by the s_id
column, which is a foreign key to the servers
table. I want to retrieve the files name, size, time it was uploaded and what server it's on. I tried this:
public function get_file_details()
{
$sql= 'SELECT name, size, uploaded, server
FROM `files` f
JOIN `servers` s
ON f.s_id = s.u_id
WHERE f_id = ?
LIMIT 1';
}
but it doesn't work. What am I doing wrong?