本文整理汇总了PHP中DBUtils::get方法的典型用法代码示例。如果您正苦于以下问题:PHP DBUtils::get方法的具体用法?PHP DBUtils::get怎么用?PHP DBUtils::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBUtils
的用法示例。
在下文中一共展示了DBUtils::get方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
function execute(&$controller, &$request, &$user)
{
$uri = $request->getParameter('uri');
$member = $user->getAttribute('member', GLU_NS);
$redirect = $request->hasParameter('redirect') ? $request->getParameter('redirect') : null;
$cc_id = $this->getContentCategoryIdByUri($uri) ? $this->getContentCategoryIdByUri($uri) : 8;
// get feed
$f = new FeedParser($uri);
$parse_result = $f->parse();
if ($parse_result === false) {
trigger_error(__CLASS__ . '::' . __FUNCTION__ . '(): ' . "Failed to parse feed uri: {$uri}", E_USER_NOTICE);
header('Content-Type: text/plain; charset=utf-8');
echo 'false';
return VIEW_NONE;
}
$name = $f->getTitle();
$favicon = $f->getFavicon() ? $f->getFavicon() : SCRIPT_PATH . 'images/favicon.ico';
$db =& DBUtils::connect(false);
$db->query('BEGIN');
// get feedId
$feedId = $this->getFeedIdByUri($uri);
if ($feedId === false) {
// add feed
$fields = array('uri' => $uri, 'link' => $f->getLink(), 'title' => $f->getTitle(), 'description' => $f->getDescription(), 'favicon' => $favicon, 'lastupdatedtime' => date("Y-m-d H:i:s"));
$res = $db->autoExecute('feed', $fields, DB_AUTOQUERY_INSERT);
if (DB::isError($res)) {
$db->rollback();
trigger_error(__CLASS__ . '::' . __FUNCTION__ . '(): ' . "Failed to insert. " . $res->toString(), E_USER_ERROR);
header('Content-Type: text/plain; charset=utf-8');
echo 'false';
return VIEW_NONE;
}
// specific mysql
$feedId = $db->getOne('SELECT LAST_INSERT_ID()');
}
// add member_to_feed
$m2f_fields = array('member_id' => MemberUtils::get_id_by_account($member->account), 'feed_id' => $feedId);
if (DBUtils::get('member_to_feed', $m2f_fields)) {
echo "'already exists'";
// already exists
return VIEW_NONE;
}
$res = $db->autoExecute('member_to_feed', $m2f_fields, DB_AUTOQUERY_INSERT);
if (DB::isError($res)) {
$db->rollback();
trigger_error(__CLASS__ . '::' . __FUNCTION__ . '(): ' . "Failed to insert m2f. " . $res->toString(), E_USER_WARNING);
header('Content-Type: text/plain; charset=utf-8');
echo 'false';
return VIEW_NONE;
}
// add member_to_content_category_to_feed
$m2cc2f_fields = array('member_id' => $member->id, 'content_category_id' => $cc_id, 'feed_id' => $feedId);
$sql = "SELECT count(*)\n FROM member_to_content_category_to_feed\n WHERE member_id = ?\n AND content_category_id = ?\n AND feed_id = ? ";
if ($db->getOne($sql, array_values($m2cc2f_fields)) == 0) {
$res = $db->autoExecute('member_to_content_category_to_feed', $m2cc2f_fields, DB_AUTOQUERY_INSERT);
if (DB::isError($res)) {
$db->rollback();
trigger_error(__CLASS__ . '::' . __FUNCTION__ . '(): ' . 'Failed to insert m2cc2f. ' . $res->toString(), E_USER_WARNING);
header('Content-Type: text/plain; charset=utf-8');
echo 'false';
return VIEW_NONE;
}
}
// try to crawl
$crawler =& new Crawler();
$crawl_result = $crawler->crawl($uri);
if ($crawl_result === false) {
$db->rollback();
trigger_error("AddFeedAction::execute(): Failed to crawl: {$uri}", E_USER_NOTICE);
header('Content-Type: text/plain; charset=utf-8');
echo 'false';
return VIEW_NONE;
}
$db->commit();
if ($redirect) {
Controller::redirect(SCRIPT_PATH . 'setting/feed');
} else {
header('Content-Type: text/plain; charset=utf-8');
echo 'true';
}
return VIEW_NONE;
}