private function selectQuery(OnpubQueryOptions $queryOptions = NULL) { if ($queryOptions === NULL) { $queryOptions = new OnpubQueryOptions(); } $where = ""; $orderBy = ""; $limit = ""; if ($queryOptions->dateLimit) { $where = "WHERE images.created <= " . $this->pdo->quote($queryOptions->dateLimit->format('Y-m-d H:i:s')); } if ($queryOptions->orderBy) { $orderBy = "ORDER BY " . $queryOptions->orderBy; if ($queryOptions->order) { $orderBy .= " " . $queryOptions->order; } } if ($queryOptions->getPage() && $queryOptions->rowLimit && $queryOptions->rowLimit > 0) { $limit = "LIMIT " . ($queryOptions->getPage() - 1) * $queryOptions->rowLimit . "," . $queryOptions->rowLimit; } elseif ($queryOptions->rowLimit && $queryOptions->rowLimit > 0) { $limit = "LIMIT 0," . $queryOptions->rowLimit; } return "SELECT images.ID, images.websiteID, images.fileName, " . "images.description, images.url, images.created, images.modified, " . "website.imageID as websiteImageID, website.name as websiteName, " . "website.url as websiteURL, website.imagesURL as websiteImagesURL, " . "website.imagesDirectory as websiteImagesDirectory, website.created " . "as websiteCreated, website.modified as websiteModified FROM " . "OnpubImages as images LEFT JOIN OnpubWebsites as website ON " . "images.websiteID = website.ID {$where} {$orderBy} {$limit}"; }
private function selectQuery(OnpubQueryOptions $queryOptions = NULL, $websiteID, $parentID) { if ($websiteID) { $websiteID = ctype_digit($websiteID) ? $websiteID : $this->pdo->quote($websiteID); } if ($parentID) { $parentID = ctype_digit($parentID) ? $parentID : $this->pdo->quote($parentID); } if ($queryOptions === NULL) { $queryOptions = new OnpubQueryOptions(); } $where = ""; $orderBy = ""; $limit = ""; if ($queryOptions->dateLimit) { $where = "WHERE created <= " . $this->pdo->quote($queryOptions->dateLimit->format('Y-m-d H:i:s')); if ($websiteID) { $where .= " AND websiteID = {$websiteID}"; } elseif ($parentID) { $where .= " AND parentID = {$parentID}"; } } else { if ($websiteID) { $where = "WHERE websiteID = {$websiteID}"; } elseif ($parentID) { $where = "WHERE parentID = {$parentID}"; } } if ($queryOptions->orderBy) { $orderBy = "ORDER BY " . $queryOptions->orderBy; if ($queryOptions->order) { $orderBy .= " " . $queryOptions->order; } } if ($queryOptions->getPage() && $queryOptions->rowLimit && $queryOptions->rowLimit > 0) { $limit = "LIMIT " . ($queryOptions->getPage() - 1) * $queryOptions->rowLimit . "," . $queryOptions->rowLimit; } elseif ($queryOptions->rowLimit && $queryOptions->rowLimit > 0) { $limit = "LIMIT 0," . $queryOptions->rowLimit; } return "SELECT ID, imageID, websiteID, parentID, name, url, created, modified FROM OnpubSections {$where} {$orderBy} {$limit}"; }
private function selectQuery(OnpubQueryOptions $queryOptions = NULL, $sectionID = NULL, $websiteID = NULL) { if ($sectionID) { $sectionID = ctype_digit($sectionID) ? $sectionID : $this->pdo->quote($sectionID); } if ($websiteID) { $websiteID = ctype_digit($websiteID) ? $websiteID : $this->pdo->quote($websiteID); } if ($queryOptions === NULL) { $queryOptions = new OnpubQueryOptions(); } $articleColumns = "articles.ID, articles.imageID, articles.title, " . "articles.url, articles.created, articles.modified, " . "articleimages.websiteID AS imageWebsiteID, articleimages.fileName AS imageFileName, " . "articleimages.description AS imageDescription, articleimages.url AS " . "articleImageURL, articleimages.created AS imageCreated, " . "articleimages.modified AS imageModified"; $where = ""; $orderBy = ""; $limit = ""; if ($queryOptions->includeContent) { $articleColumns = "articles.ID, articles.imageID, articles.title, " . "articles.content, articles.url, articles.created, " . "articles.modified, articleimages.websiteID AS " . "imageWebsiteID, articleimages.fileName AS " . "imageFileName, articleimages.description AS " . "imageDescription, articleimages.url AS " . "articleImageURL, articleimages.created AS " . "imageCreated, articleimages.modified AS imageModified"; } if ($sectionID || $websiteID) { $articleColumns .= ", samaps.sectionID AS sectionID"; } if ($queryOptions->dateLimit) { $where = "WHERE articles.created <= " . $this->pdo->quote($queryOptions->dateLimit->format('Y-m-d H:i:s')); if ($sectionID && !$websiteID) { $where .= " AND samaps.sectionID = {$sectionID}"; } if ($websiteID && !$sectionID) { $where .= " AND wsmaps.websiteID = {$websiteID}"; } } else { if ($sectionID && !$websiteID) { $where = "WHERE samaps.sectionID = {$sectionID}"; } if ($websiteID && !$sectionID) { $where = "WHERE wsmaps.websiteID = {$websiteID}"; } } if ($queryOptions->orderBy) { $orderBy = "ORDER BY articles." . $queryOptions->orderBy; if ($queryOptions->order) { $orderBy .= " " . $queryOptions->order; } } else { if ($sectionID && !$websiteID) { $orderBy = "ORDER BY samaps.ID ASC"; } } if ($queryOptions->getPage() && $queryOptions->rowLimit && $queryOptions->rowLimit > 0) { $limit = "LIMIT " . ($queryOptions->getPage() - 1) * $queryOptions->rowLimit . "," . $queryOptions->rowLimit; } elseif ($queryOptions->rowLimit && $queryOptions->rowLimit > 0) { $limit = "LIMIT 0," . $queryOptions->rowLimit; } if ($sectionID && !$websiteID) { return "SELECT {$articleColumns} FROM OnpubArticles AS articles LEFT JOIN " . "OnpubImages AS articleimages ON articles.imageID = articleimages.ID LEFT JOIN " . "OnpubSAMaps AS samaps ON articles.ID = samaps.articleID " . "{$where} {$orderBy} {$limit}"; } elseif ($websiteID && !$sectionID) { return "SELECT {$articleColumns} FROM OnpubArticles AS articles LEFT JOIN " . "OnpubImages AS articleimages ON articles.imageID = articleimages.ID LEFT JOIN " . "OnpubSAMaps AS samaps ON articles.ID = samaps.articleID " . "LEFT JOIN OnpubWSMaps AS wsmaps ON samaps.sectionID = " . "wsmaps.sectionID {$where} {$orderBy} {$limit}"; } else { return "SELECT {$articleColumns} FROM OnpubArticles AS articles LEFT JOIN " . "OnpubImages AS articleimages ON articles.imageID = articleimages.ID " . "{$where} {$orderBy} {$limit}"; } }
private function selectQuery(OnpubQueryOptions $queryOptions = NULL, $sectionID = NULL, $articleID = NULL) { if ($sectionID) { $sectionID = ctype_digit($sectionID) ? $sectionID : $this->pdo->quote($sectionID); } if ($articleID) { $articleID = ctype_digit($articleID) ? $articleID : $this->pdo->quote($articleID); } if ($queryOptions === NULL) { $queryOptions = new OnpubQueryOptions(); } $where = ""; $orderBy = ""; $limit = ""; if ($queryOptions->dateLimit) { $where = "WHERE created <= " . $this->pdo->quote($queryOptions->dateLimit->format('Y-m-d H:i:s')); if ($sectionID) { $where .= " AND sectionID = {$sectionID}"; } elseif ($articleID) { $where .= " AND articleID = {$articleID}"; } } else { if ($sectionID) { $where = "WHERE sectionID = {$sectionID}"; } elseif ($articleID) { $where = "WHERE articleID = {$articleID}"; } } if ($queryOptions->orderBy) { $orderBy = "ORDER BY " . $queryOptions->orderBy; if ($queryOptions->order) { $orderBy .= " " . $queryOptions->order; } } if ($queryOptions->getPage() && $queryOptions->rowLimit && $queryOptions->rowLimit > 0) { $limit = "LIMIT " . ($queryOptions->getPage() - 1) * $queryOptions->rowLimit . "," . $queryOptions->rowLimit; } elseif ($queryOptions->rowLimit && $queryOptions->rowLimit > 0) { $limit = "LIMIT 0," . $queryOptions->rowLimit; } return "SELECT ID, sectionID, articleID, created, modified FROM OnpubSAMaps {$where} {$orderBy} {$limit}"; }
private function selectQuery(OnpubQueryOptions $queryOptions = NULL) { if ($queryOptions === NULL) { $queryOptions = new OnpubQueryOptions(); } $where = ""; $orderBy = ""; $limit = ""; if ($queryOptions->dateLimit) { $where = "WHERE created <= " . $this->pdo->quote($queryOptions->dateLimit->format('Y-m-d H:i:s')); } if ($queryOptions->orderBy) { $orderBy = "ORDER BY " . $queryOptions->orderBy; if ($queryOptions->order) { $orderBy .= " " . $queryOptions->order; } } if ($queryOptions->getPage() && $queryOptions->rowLimit && $queryOptions->rowLimit > 0) { $limit = "LIMIT " . ($queryOptions->getPage() - 1) * $queryOptions->rowLimit . "," . $queryOptions->rowLimit; } elseif ($queryOptions->rowLimit && $queryOptions->rowLimit > 0) { $limit = "LIMIT 0," . $queryOptions->rowLimit; } return "SELECT ID, imageID, givenNames, familyName, displayAs, url, created, modified FROM OnpubAuthors {$where} {$orderBy} {$limit}"; }