本文整理汇总了PHP中Criteria::setExplicitQuery方法的典型用法代码示例。如果您正苦于以下问题:PHP Criteria::setExplicitQuery方法的具体用法?PHP Criteria::setExplicitQuery怎么用?PHP Criteria::setExplicitQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Criteria
的用法示例。
在下文中一共展示了Criteria::setExplicitQuery方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: selectPagesByParent
public function selectPagesByParent($categoryId, $parentId)
{
$c = new Criteria();
$categoryId = (int) $categoryId;
$parentId = (int) $parentId;
if ($parentId) {
$c->setExplicitQuery("SELECT * FROM page WHERE category_id = {$categoryId} AND parent_page_id = {$parentId}");
} else {
$c->setExplicitQuery("SELECT * FROM page WHERE category_id = {$categoryId} AND parent_page_id IS NULL");
}
return DB_PagePeer::instance()->select($c);
}
示例2: build
public function build($runData)
{
$site = $runData->getTemp("site");
$pl = $runData->getParameterList();
$themeId = $pl->getParameterValue('theme_id');
if ($themeId === null) {
$themeUrl = current($_GET);
// BAD HACK!!!
if ($themeUrl) {
$theme = $this->getExternalTheme($themeUrl);
} else {
$page = $runData->getTemp("page");
if ($page == null) {
throw new ProcessException(_("Not working in the preview mode. Not a preview mode? So it might be an error."));
}
$theme = $page->getCategory()->getTheme();
}
} else {
$theme = DB_ThemePeer::instance()->selectByPrimaryKey($themeId);
}
//$this->themeId = $themeId;
if ($theme == null || $theme->getAbstract() == true || $theme->getCustom == true && $theme->getSiteId() != $site->getSiteId()) {
throw new ProcessException(_("Error selecting theme."));
}
$this->theme = $theme;
$q = "SELECT * from theme WHERE " . "abstract = FALSE " . "AND (custom = FALSE" . " OR (custom = TRUE AND site_id='" . $site->getSiteId() . "' AND site_id !=1)" . ") " . "ORDER BY custom, sort_index, replace(name, '_', '00000000');";
$c = new Criteria();
$c->setExplicitQuery($q);
$themes = DB_ThemePeer::instance()->select($c);
$runData->contextAdd("themes", $themes);
$runData->contextAdd("currentTheme", $theme);
$runData->contextAdd("noUi", $pl->getParameterValue('noUi'));
}
示例3: getFiles
public function getFiles()
{
$q = "SELECT * FROM file WHERE page_id='" . $this->getPageId() . "' ORDER BY filename, file_id DESC";
$c = new Criteria();
$c->setExplicitQuery($q);
return DB_FilePeer::instance()->select($c);
}
示例4: build
public function build($runData)
{
$pl = $runData->getParameterList();
$totalAll = (bool) $pl->getParameterValue('totalAll');
$user = $runData->getUser();
$c = new Criteria();
if ($totalAll) {
$q = "SELECT site.* FROM site, member WHERE member.user_id = '{$user->getUserId()}' AND member.site_id = site.site_id " . "ORDER BY site.name";
$c->setExplicitQuery($q);
$ss = DB_SitePeer::instance()->select($c);
$sites = array();
foreach ($ss as $s) {
$sites[$s->getUnixName()] = array('site' => $s);
}
} else {
$q = "SELECT email_list.* FROM email_list, email_list_subscriber, site WHERE email_list_subscriber.user_id = {$user->getUserId()} " . "AND email_list_subscriber.list_id = email_list.list_id AND email_list.site_id = site.site_id " . "ORDER BY site.name, email_list.title";
$c->setExplicitQuery($q);
$lists = DB_EmailListPeer::instance()->select($c);
// sorry for the DIIIIRTY STYLE!!!
$sites = array();
foreach ($lists as $l) {
$s = DB_SitePeer::instance()->selectByPrimaryKey($l->getSiteId());
if (!isset($sites[$s->getUnixName()])) {
$sites[$s->getUnixName()] = array('site' => $s, 'lists' => array());
}
$sites[$s->getUnixName()]['lists'][] = $l;
$l->setTemp('site', $s);
}
}
$runData->contextAdd('lists', $lists);
$runData->contextAdd('sites', $sites);
$runData->contextAdd('totalAll', $totalAll);
$runData->contextAdd('user', $user);
}
示例5: build
public function build($runData)
{
$user = $runData->getUser();
$c = new Criteria();
$pl = $runData->getParameterList();
$siteId = $pl->getParameterValue('siteId');
$all = (bool) $pl->getParameterValue('all');
$site = DB_SitePeer::instance()->selectByPrimaryKey($siteId);
if ($all) {
$q = "SELECT email_list.* FROM email_list WHERE " . "email_list.site_id = '{$site->getSiteId()}' " . "ORDER BY email_list.title";
$c->setExplicitQuery($q);
$lists = DB_EmailListPeer::instance()->select($c);
// check if subscribed
foreach ($lists as $list) {
$c2 = new Criteria();
$c2->add('user_id', $user->getUserId());
$c2->add('list_id', $list->getListId());
$sub = DB_EmailListSubscriberPeer::instance()->selectOne($c2);
if ($sub) {
$list->setTemp('subscribed', true);
}
}
} else {
// only subscribed
$q = "SELECT email_list.* FROM email_list, email_list_subscriber WHERE email_list_subscriber.user_id = {$user->getUserId()} " . "AND email_list_subscriber.list_id = email_list.list_id AND email_list.site_id = '{$site->getSiteId()}' " . "ORDER BY email_list.title";
$c->setExplicitQuery($q);
$lists = DB_EmailListPeer::instance()->select($c);
foreach ($lists as $list) {
$list->setTemp('subscribed', true);
}
}
$runData->contextAdd('all', $all);
$runData->contextAdd('lists', $lists);
$runData->contextAdd('site', $site);
}
示例6: getSourceText
public function getSourceText()
{
if ($this->getDiffSource() == false) {
$c = new Criteria();
$c->add("source_id", $this->getSourceId());
$source = DB_PageSourcePeer::instance()->selectOne($c);
return $source->getText();
} else {
// select last revisions and sources.
$q = "SELECT page_source.* FROM page_source, page_revision WHERE " . "page_revision.page_id =" . $this->getPageId() . " " . "AND page_revision.revision_id <= " . $this->getRevisionId() . " " . "AND (page_revision.flag_text = TRUE OR page_revision.flag_new = TRUE) " . "AND page_revision.source_id = page_source.source_id " . "ORDER BY page_revision.revision_id DESC " . "LIMIT " . ($this->getSinceFullSource() + 1);
$c = new Criteria();
$c->setExplicitQuery($q);
$sources = DB_PageSourcePeer::instance()->select($c);
// original source...
$s = end($sources);
$s0 = $s->getText();
$differ = new ODiff();
while ($s = prev($sources)) {
$s0 = $differ->patchString($s0, $s->getText());
if ($differ->getErrors() != null) {
return "Error processing the source - please report the problem to the support";
}
}
return trim($s0);
}
}
示例7: build
public function build($runData)
{
$pl = $runData->getParameterList();
$site = $runData->getTemp("site");
$root = $pl->getParameterValue("root");
$showRoot = $pl->getParameterValue("showRoot");
if (!$root) {
$page = $runData->getTemp("page");
} else {
$page = DB_PagePeer::instance()->selectByName($site->getSiteId(), $root);
}
if (!$page) {
$runData->setModuleTemplate("Empty");
return;
}
$depth = $pl->getParameterValue("depth");
if (!$depth || !is_numeric($depth) || $depth < 1) {
$depth = 5;
}
$tree = array();
$c = new Criteria();
$c->add("parent_page_id", $page->getPageId());
$c->addOrderAscending("COALESCE(title, unix_name)");
$children = DB_PagePeer::instance()->select($c);
$descendants = array();
// select next level of children
$ch1 = $children;
$d = 0;
while ($ch1 != null && count($ch1) > 0 && (!$depth || $d < $depth)) {
$q = "SELECT * FROM page WHERE parent_page_id IN (";
$tch = array();
foreach ($ch1 as $ch) {
// check if already in the $tch
if (!array_key_exists($ch->getPageId(), $descendants)) {
$tch[] = $ch->getPageId();
$descendants[$ch->getParentPageId()][] = $ch;
} else {
$ch->setTemp('circular', true);
$descendants[$ch->getParentPageId()][] = $ch;
}
}
if (count($tch) > 0) {
$q .= implode(',', $tch);
$q .= ") ORDER BY COALESCE(title, unix_name)";
$c = new Criteria();
$c->setExplicitQuery($q);
$ch2 = DB_PagePeer::instance()->select($c);
$ch1 = $ch2;
} else {
$ch1 = null;
}
$d++;
}
$runData->contextAdd("root", $page);
$runData->contextAdd("children", $descendants);
if ($showRoot) {
$runData->contextAdd("showRoot", true);
}
}
示例8: build
public function build($runData)
{
$site = $runData->getTemp("site");
$siteId = $site->getSiteId();
$q = "SELECT *, count(*) AS number_links FROM page, page_link " . "WHERE page.site_id = '{$siteId}' AND page_link.to_page_id=page.page_id " . "GROUP BY (page.page_id) " . "ORDER BY COALESCE(page.title, page.unix_name)";
$q = "SELECT * FROM page " . "WHERE page.site_id = '{$siteId}'" . "AND (SELECT count(*) FROM page_link WHERE page_link.to_page_id = page.page_id) = 0 " . "ORDER BY COALESCE(page.title, page.unix_name)";
$c = new Criteria();
$c->setExplicitQuery($q);
$pages = DB_PagePeer::instance()->select($c);
$runData->contextAdd("pages", $pages);
}
示例9: build
public function build($runData)
{
$user = $runData->getUser();
$runData->contextAdd("user", $user);
$pl = $runData->getParameterList();
// get watched pages for this user
$c = new Criteria();
$q = "SELECT page.* FROM watched_page, page " . "WHERE watched_page.user_id='" . $user->getUserId() . "' " . "AND watched_page.page_id=page.page_id";
$c->setExplicitQuery($q);
$pages = DB_PagePeer::instance()->select($c);
$runData->contextAdd("pages", $pages);
$runData->contextAdd("pagesCount", count($pages));
}
示例10: build
public function build($runData)
{
$page = $runData->getTemp("page");
if (!$page) {
return;
}
$pageId = $page->getPageId();
// create a very custom query ;-)
$c = new Criteria();
$q = "SELECT page_id, title, unix_name FROM page_link, page " . "WHERE page_link.to_page_id='" . db_escape_string($pageId) . "' " . "AND page_link.from_page_id=page.page_id ORDER BY COALESCE(title, unix_name)";
$c->setExplicitQuery($q);
$pages = DB_PagePeer::instance()->select($c);
$runData->contextAdd("pages", $pages);
}
示例11: build
public function build($runData)
{
$site = $runData->getTemp("site");
$runData->contextAdd("site", $site);
$runData->contextAdd("settings", $site->getSettings());
$runData->contextAdd("superSettings", $site->getSuperSettings());
// get the viewers
$c = new Criteria();
$q = "SELECT ozone_user.* FROM ozone_user, site_viewer WHERE site_viewer.site_id='" . $site->getSiteId() . "' " . "AND ozone_user.user_id = site_viewer.user_id ORDER BY ozone_user.nick_name";
$c->setExplicitQuery($q);
$viewers = DB_OzoneUserPeer::instance()->select($c);
$runData->contextAdd("viewers", $viewers);
$runData->contextAdd("settings", $site->getSettings());
}
示例12: build
public function build($runData)
{
$site = $runData->getTemp("site");
$runData->contextAdd("site", $site);
// get all categories for the site
$c = new Criteria();
$c->add("site_id", $site->getSiteId());
$c->addOrderAscending("replace(name, '_', '00000000')");
$categories = DB_CategoryPeer::instance()->select($c);
$runData->contextAdd("categories", $categories);
// also prepare categories to put into javascript...
$cats2 = array();
foreach ($categories as $category) {
$arr = $category->getFieldValuesArray();
// change themes to conform to variants structure
if ($arr['theme_id']) {
$theme = DB_ThemePeer::instance()->selectByPrimaryKey($category->getThemeId());
if ($theme->getVariantOfThemeId() != null) {
$arr['theme_id'] = $theme->getVariantOfThemeId();
$arr['variant_theme_id'] = $theme->getThemeId();
$arr['theme_external_url'] = $category->getThemeExternalUrl();
}
}
$cats2[] = $arr;
}
$runData->ajaxResponseAdd("categories", $cats2);
// now select themes
$c = new Criteria();
/*$c->add("custom", false);
$c->add("abstract", false);
$c->addOrderAscending("name");*/
$q = "SELECT * from theme WHERE " . "abstract = FALSE AND variant_of_theme_id IS NULL " . "AND (custom = FALSE" . " OR (custom = TRUE AND site_id='" . $site->getSiteId() . "')" . ") " . "ORDER BY custom, sort_index, replace(name, '_', '00000000');";
$c->setExplicitQuery($q);
$themes = DB_ThemePeer::instance()->select($c);
$runData->contextAdd("themes", $themes);
// get theme variants too
$c = new Criteria();
$q = "SELECT * FROM theme WHERE variant_of_theme_id IS NOT NULL ORDER BY name";
$c->setExplicitQuery($q);
$variants = DB_ThemePeer::instance()->select($c);
$variantsArray = array();
foreach ($variants as $v) {
$variantsArray[$v->getVariantOfThemeId()][] = $v;
}
$runData->contextAdd("variantsArray", $variantsArray);
}
示例13: build
public function build($runData)
{
$site = $runData->getTemp("site");
$showAll = (bool) $runData->getParameterList()->getParameterValue("showAll");
// get invitations
$c = new Criteria();
if (!$showAll) {
$q = "SELECT * FROM email_invitation, admin " . "WHERE admin.site_id='" . $site->getSiteId() . "' " . "AND email_invitation.site_id='" . $site->getSiteId() . "' " . "AND admin.user_id = email_invitation.user_id ORDER BY invitation_id DESC";
$c->setExplicitQuery($q);
} else {
$c->add("site_id", $site->getSiteId());
$c->addOrderDescending("invitation_id");
}
$invitations = DB_EmailInvitationPeer::instance()->select($c);
$runData->contextAdd("invitations", $invitations);
$runData->contextAdd("showAll", $showAll);
}
示例14: build
public function build($runData)
{
$pl = $runData->getParameterList();
$categoryId = $pl->getParameterValue("c");
$pageNumber = $pl->getParameterValue("p");
if ($pageNumber == null || !is_numeric($pageNumber) || $pageNumber < 1) {
$pageNumber = 1;
}
$sort = $pl->getParameterValue("sort");
// the criteria is: have >= 20 edits.
// first - count them all
//$q =
$c = new Criteria();
$q = "SELECT site.* FROM site WHERE site.visible = TRUE AND site.private = FALSE AND site.deleted = FALSE AND site.site_id != 1 AND (SELECT count(*) FROM page WHERE page.site_id = site.site_id) > 15 ORDER BY site.name";
$c->setExplicitQuery($q);
$sites = DB_SitePeer::instance()->select($c);
$runData->contextAdd("sites", $sites);
}
示例15: build
public function build($runData)
{
$pageId = $runData->getParameterList()->getParameterValue("page_id");
if (!$pageId || !is_numeric($pageId)) {
throw new ProcessException(_("The page can not be found or does not exist."), "no_page");
}
// create a very custom query ;-)
$c = new Criteria();
$q = "SELECT page_id, title, unix_name FROM page_link, page " . "WHERE page_link.to_page_id='" . db_escape_string($pageId) . "' " . "AND page_link.from_page_id=page.page_id ORDER BY COALESCE(title, unix_name)";
$c->setExplicitQuery($q);
$pages = DB_PagePeer::instance()->select($c);
$q = "SELECT page_id, title, unix_name FROM page, page_inclusion " . "WHERE page_inclusion.included_page_id='" . db_escape_string($pageId) . "' " . "AND page_inclusion.including_page_id=page.page_id ORDER BY COALESCE(title, unix_name)";
$c->setExplicitQuery($q);
$pagesI = DB_PagePeer::instance()->select($c);
$runData->contextAdd("pagesI", $pagesI);
$runData->contextAdd("pages", $pages);
$runData->contextAdd("pagesCount", count($pages));
}