当前位置: 首页>>代码示例>>PHP>>正文


PHP Context::fetchPairs方法代码示例

本文整理汇总了PHP中Nette\Database\Context::fetchPairs方法的典型用法代码示例。如果您正苦于以下问题:PHP Context::fetchPairs方法的具体用法?PHP Context::fetchPairs怎么用?PHP Context::fetchPairs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Nette\Database\Context的用法示例。


在下文中一共展示了Context::fetchPairs方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get

 public function get($id)
 {
     $clanek = $this->database->fetch("SELECT c.*, cr.perex, cr.text,cr.datum as aktualizovano, k.nazev as kategorie,cr.id as crid,\n                                                      ko.komentaru, u.alt, u.title\n                                        FROM clanky c\n                                        JOIN (select * from clanky_revize where id in (SELECT max(id) from clanky_revize group by clanek_id )) cr ON (c.id=cr.clanek_id)\n                                        JOIN kategorie k ON (c.kategorie_id = k.id)\n                                        LEFT JOIN (select clanek_id,count(*) as komentaru from komentare group by clanek_id) ko ON (ko.clanek_id=c.id)\n                                        LEFT JOIN upload u ON (c.obrazek_id = u.id)\n                                        WHERE c.id=? and c.smazano=0 ORDER BY cr.id DESC LIMIT 1;", $id);
     $stitky = $this->database->fetchPairs("SELECT stitek FROM stitky WHERE clanek_id=?;", $id);
     if (!empty($clanek)) {
         $clanek->stitky = array_unique($stitky);
     }
     return $clanek;
 }
开发者ID:stanley89,项目名称:piratskelisty,代码行数:9,代码来源:Clanky.php

示例2: actionDefault

    public function actionDefault($param)
    {
        // Yes, I hate this code, too.
        // Yes, it was the fastest way to build a prototype.
        // Yes, it would just kill the database server later on.
        // No, do not use anywhere.
        // Yes, you have just been warned.
        $this->tags = array_filter(preg_split('/\\s+/', $param));
        if (empty($this->tags)) {
            $query = 'SELECT * FROM urls';
        } else {
            $query = 'SELECT * FROM urls WHERE id IN (
				SELECT s1.url_id FROM
					(SELECT ut.url_id FROM url_tags ut JOIN tags t ON ut.tag_id = t.id WHERE t.tag IN (?)) s1' . "\n";
            for ($i = 2; $i <= count($this->tags); $i++) {
                $query .= "JOIN (SELECT ut.url_id FROM url_tags ut JOIN tags t ON ut.tag_id = t.id WHERE t.tag IN (?)) s{$i} ON s1.url_id = s{$i}.url_id\n";
            }
            $query .= ')';
        }
        $result = call_user_func_array([$this->database, 'fetchAll'], array_merge([$query], $this->tags));
        $urls = array();
        foreach ($result as $url) {
            $urls[$url->id] = $url;
            $urls[$url->id]->tags = array();
        }
        if (!empty($urls)) {
            $urlTags = $this->database->fetchAll('
				SELECT
					ut.url_id AS urlId,
					t.tag,
					tc.category AS category
				FROM
					tags t
					JOIN url_tags ut ON t.id = ut.tag_id
					LEFT JOIN tag_categories tc ON t.category_id = tc.id
				WHERE
					ut.url_id IN (?)
				ORDER BY
					t.category_id,
					t.tag
			', array_keys($urls));
            foreach ($urlTags as $tag) {
                $urls[$tag->urlId]->tags[] = $tag;
            }
        }
        $allTags = array_values($this->database->fetchPairs('SELECT id, tag FROM tags ORDER BY tag'));
        $this->template->tags = $this->tags;
        $this->template->urls = $urls;
        $this->template->allTags = $allTags;
    }
开发者ID:spaze,项目名称:cotel,代码行数:50,代码来源:HomepagePresenter.php

示例3: getRolePairs

 public function getRolePairs()
 {
     return $this->database->fetchPairs("SELECT id, nazev FROM role;");
 }
开发者ID:stanley89,项目名称:piratskelisty,代码行数:4,代码来源:Uzivatele.php

示例4: getPairs

 public function getPairs()
 {
     return $this->database->fetchPairs("SELECT id, alt from upload order by id desc;");
 }
开发者ID:stanley89,项目名称:piratskelisty,代码行数:4,代码来源:Upload.php


注:本文中的Nette\Database\Context::fetchPairs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。