I have a table called cms_page in which each page has an ID. I want to pull all the information from this table and all the information from cms_page_part table where page_id is equal to the ID i send to the page...confusing i know but here is my attempt:
require '../../config.php';
$conn = new PDO(DB_DSN, DB_USER, DB_PASS);
$id = (int)$_GET['id'];
//$q = $conn->query("SELECT * FROM cms_page WHERE id=$id");
$q = $conn->query("SELECT cms_page.id, cms_page.title, cms_page.slug, cms_page_part.* FROM cms_page LEFT JOIN cms_page_part ON cms_page_part.page_id=cms_page.id WHERE cms_page.id = $id");
$project = $q->fetch(PDO::FETCH_ASSOC);
Any help figuring out how to join these would be appreciated.