本文整理汇总了PHP中Nette\Database\Context::fetchField方法的典型用法代码示例。如果您正苦于以下问题:PHP Context::fetchField方法的具体用法?PHP Context::fetchField怎么用?PHP Context::fetchField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Database\Context
的用法示例。
在下文中一共展示了Context::fetchField方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadLob
public function loadLob()
{
$stop = $this->database->fetchField("select max(unix_timestamp(published))>(unix_timestamp(now())-100) from lob_items;");
if ($stop) {
return;
}
$channels = $this->getLobChannels();
foreach ($channels as $channel) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $channel['link']);
$redirects = 0;
$page = $this->curl_redirect_exec($ch, $redirects, true);
curl_close($ch);
if (empty($page)) {
continue;
}
$html = HtmlDomParser::str_get_html($page);
foreach ($html->find('#page-body .post') as $element) {
if (isset($element->id)) {
$id = preg_replace("/[^0-9,.]/", "", $element->id);
} else {
continue;
}
$lobItem = $this->getLobItemByPostId($id);
if (!empty($lobItem)) {
continue;
}
$arr = array();
$content = $element->find('.content', 0);
$author = $element->find('.postprofile dt', 0);
$datestring = $element->find('.author', 0);
$arr['content'] = trim($content->innertext);
$arr['author'] = trim($author->plaintext);
$arr['datestring'] = trim(preg_replace("/.*»/", "", $datestring->innertext));
$arr['post_id'] = $id;
$this->database->query('insert into lob_items ', $arr);
}
}
}
示例2: getByStareId
public function getByStareId($stare_id)
{
$id = $this->database->fetchField("SELECT id FROM clanky WHERE stare_id=?;", $stare_id);
return $this->get($id);
}