本文整理汇总了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;
}
示例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;
}
示例3: getRolePairs
public function getRolePairs()
{
return $this->database->fetchPairs("SELECT id, nazev FROM role;");
}
示例4: getPairs
public function getPairs()
{
return $this->database->fetchPairs("SELECT id, alt from upload order by id desc;");
}