'ello all.
Constructing queries has never been a strength of mine, but I would like to get better.
I have the following query which returns the "plugin id (pid)" of all plugins that are supposed to be on a page based on a "category id (cid)" that matches the current page.
$category = 1;
$sql = "SELECT PR.id, PR.name, PR.indexPath, CP.location";
$sql .= " FROM ".DB_PREFIX."pluginRegistry AS PR";
$sql .= ", ".DB_PREFIX."categoryPlugins AS CP, ".DB_PREFIX."categories AS C";
$sql .= " WHERE CP.pid=PR.id AND C.id='$category'";
This works and returns the 2 results I expect, but I don't think this is a very efficient query. Could someone assist me? I have a feeling it will turn into a JOIN, but I don't really understand the entire construction of those queries, just that they work.
DB Schema:
categories -> id | name | url
categoryPlugins -> id | cid | pid | location
pluginRegistry -> id | name | indexPath
TIA!