本文整理汇总了PHP中Typecho_Db::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Typecho_Db::get方法的具体用法?PHP Typecho_Db::get怎么用?PHP Typecho_Db::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Typecho_Db
的用法示例。
在下文中一共展示了Typecho_Db::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* 构造函数,初始化组件
*
* @access public
* @param mixed $request request对象
* @param mixed $response response对象
* @param mixed $params 参数列表
*/
public function __construct($request, $response, $params = NULL)
{
parent::__construct($request, $response, $params);
/** 初始化数据库 */
$this->db = Typecho_Db::get();
$this->options = $this->widget('Widget_Options');
}
示例2: links
function links($slug)
{
$db = Typecho_Db::get();
$Contents = Typecho_Widget::widget('Widget_Abstract_Contents');
$value = $db->fetchRow($db->select()->from('table.contents')->where('table.contents.status = ?', 'publish')->where('table.contents.type = ?', 'page')->where('table.contents.slug = ?', $slug)->where('table.contents.password IS NULL')->limit(1));
$value = $Contents->filter($value);
if (0 === strpos($value['text'], '<!--markdown-->')) {
$value['isMarkdown'] = 0;
} else {
$value['isMarkdown'] = 1;
}
if ($value['isMarkdown'] == 1) {
$text = substr($value['text'], 15);
$text = $Contents->markdown($text);
} else {
$text = $Contents->autoP($value['text']);
}
$search = '/<ul>(.*?)<\\/ul>/is';
preg_match_all($search, $text, $matches);
$result = '';
foreach ($matches[1] as $v) {
$result .= $v;
}
$result = str_replace('<li>', '', $result);
$result = str_replace('</li>', '<br/>', $result);
$result = rtrim($result, '<br/>');
echo $result;
}
示例3: __construct
public function __construct()
{
$this->db = Typecho_Db::get();
$this->prefix = $this->db->getPrefix();
$this->table = $this->prefix . 'access';
$this->config = Typecho_Widget::widget('Widget_Options')->plugin('Access');
$this->request = Typecho_Request::getInstance();
$this->pageSize = $this->config->pageSize;
$this->isDrop = $this->config->isDrop;
if ($this->pageSize == null || $this->isDrop == null) {
throw new Typecho_Plugin_Exception('请先设置插件!');
}
switch ($this->request->get('action')) {
case 'logs':
default:
$this->action = 'logs';
$this->title = '访问日志';
$this->parseLogs();
break;
case 'overview':
$this->action = 'overview';
$this->title = '访问概览';
$this->parseOverview();
break;
}
}
示例4: SB_tagcloud
function SB_tagcloud($param)
{
$db = Typecho_Db::get();
$text = '<aside class="widget widget-simpletags clearfix"><h3 class="widget-title"><span>标签云</span></h3><div class="st-tag-cloud">';
$sql = $db->fetchAll($db->select()->from("table.metas")->where('type = ?', 'tag')->order('count', Typecho_Db::SORT_DESC)->limit(intval($param['max']) ? intval($param['max']) : 30));
if (!empty($sql)) {
$largest = 22;
$smallest = 8;
$scale_min = 1;
$scale_max = 10;
$minout = max($scale_min, 0);
$maxout = max($scale_max, $minout);
$maxval = 0;
$minval = $sql[0]['count'];
foreach ($sql as $tag) {
if ($tag['count'] > $maxval) {
$maxval = $tag['count'];
}
if ($minval > $tag['count']) {
$minval = $tag['count'];
}
}
$scale = $maxval > $minval ? ($maxout - $minout) / ($maxval - $minval) : 0;
$obj = Typecho_Widget::widget("Widget_Abstract_Metas");
foreach ($sql as $tag) {
$tag = $obj->filter($tag);
$scale_result = ceil(($tag['count'] - $minval) * $scale + $minout);
$text .= "<a href=\"" . $tag['permalink'] . "\" title=\"" . $tag['count'] . " 个主题\" style=\"font-size:" . round(($scale_result - $scale_min) * ($largest - $smallest) / ($scale_max - $scale_min) + $smallest) . "px;color:" . get_color_by_scale(round(($scale_result - $scale_min) / ($scale_max - $scale_min) * 100) / 100, "#cccccc", "#666666") . "\">" . $tag['name'] . "</a>\n";
}
}
return $text . '</div></aside>';
}
示例5: action
public function action()
{
$this->db = Typecho_Db::get();
$this->prefix = $this->db->getPrefix();
$this->options = Typecho_Widget::widget('Widget_Options');
$cid = $this->request->cid;
if (!$cid) {
$this->response->throwJson(array('status' => 0, 'msg' => '请选择喜欢的文章!'));
}
$likes = Typecho_Cookie::get('__post_likes');
if (empty($likes)) {
$likes = array();
} else {
$likes = explode(',', $likes);
}
if (!in_array($cid, $likes)) {
$row = $this->db->fetchRow($this->db->select('likesNum')->from('table.contents')->where('cid = ?', $cid)->limit(1));
$this->db->query($this->db->update('table.contents')->rows(array('likesNum' => (int) $row['likesNum'] + 1))->where('cid = ?', $cid));
array_push($likes, $cid);
$likes = implode(',', $likes);
Typecho_Cookie::set('__post_likes', $likes);
//记录查看cookie
$this->response->throwJson(array('status' => 1, 'msg' => '成功点赞!'));
}
$this->response->throwJson(array('status' => 0, 'msg' => '你已经点赞过了!'));
}
示例6: favorite
public function favorite()
{
$user = $this->widget('Widget_User');
if (!$user->hasLogin()) {
$this->response->throwJson(array('status' => 0, 'msg' => _t('还未登录不能进行此操作!')));
}
$favorites = $this->widget('Widget_Users_Favorites');
if (!empty($this->request->fid)) {
$db = Typecho_Db::get();
$favorites->deleteFavorite($this->request->fid);
$this->response->throwJson(array('status' => 1, 'msg' => _t('已取消收藏!')));
}
//数据是否存在
if ($favorites->dataExists()) {
$this->response->throwJson(array('status' => 0, 'msg' => _t('收藏的内容不存在!')));
}
//是否已经收藏
if ($favorites->favoriteExists($favorites->parameter->type, $favorites->getSrcId())) {
$this->response->throwJson(array('status' => 0, 'msg' => _t($favorites->getTitle() . '已收藏!')));
}
$fid = $favorites->addFavorite();
if ($fid) {
$this->response->throwJson(array('status' => 1, 'fid' => $fid, 'msg' => _t($favorites->getTitle() . '已成功收藏!')));
} else {
$this->response->throwJson(array('status' => 0, 'msg' => _t('收藏出错!')));
}
}
示例7: __construct
public function __construct($request, $response, $params = NULL)
{
parent::__construct($request, $response, $params);
/* 获取数据库对象、配置及用户 */
$this->_db = Typecho_Db::get();
$this->_options = Typecho_Widget::widget('Widget_Options');
}
示例8: info
public static function info()
{
$options = Typecho_Widget::widget('Widget_Options');
$Ukagaka = $options->plugin('Ukagaka');
$wcc['notice'] = stripslashes($Ukagaka->notice);
$db = Typecho_Db::get();
$select = $db->select()->from('table.options')->where('name = ?', 'Ukagaka_starttime');
$lifetime = $db->fetchAll($select);
$lifetime = self::get_wcc_lifetime($lifetime[0]['value']);
$name = Typecho_Widget::widget('Widget_Options')->title;
$wcc['showlifetime'] = '我已经与主人 ' . $name . ' 一起生存了 <font color="red">' . $lifetime["day"] . '</font> 天 <font color="red">' . $lifetime["hours"] . '</font> 小时 <font color="red">' . $lifetime["minutes"] . '</font> 分钟 <font color="red">' . $lifetime["seconds"] . '</font> 秒的快乐时光啦~*^_^*';
$foods = explode("\r\n", $Ukagaka->foods);
foreach ($foods as $key => $value) {
$xx = explode("//", $value);
$wcc['foods'][] = $xx[0];
$wcc['eatsay'][] = $xx[1];
}
if ($Ukagaka->contact) {
$contact = explode("\r\n", $Ukagaka->contact);
foreach ($contact as $key => $value) {
$xx = explode("//", $value);
$wcc['ques'][] = $xx[0];
$wcc['ans'][] = $xx[1];
}
} else {
$wcc['contactapi'] = '1';
}
$wcc = json_encode($wcc);
echo $wcc;
}
示例9: __construct
/**
* 构造函数,初始化组件
*
* @access public
* @param mixed $request request对象
* @param mixed $response response对象
* @param mixed $params 参数列表
* @return void
*/
public function __construct($request, $response, $params = NULL)
{
parent::__construct($request, $response, $params);
/** 初始化数据库 */
$this->db = Typecho_Db::get();
/** 初始化常用组件 */
$this->user = $this->widget('Widget_User');
}
示例10: __construct
public function __construct($request, $response, $params = NULL)
{
parent::__construct($request, $response, $params);
$this->db = Typecho_Db::get();
$this->options = Helper::options();
//$this->pluginRootUrl = Typecho_Common::url('Api/', $this->options->pluginUrl);
require_once 'Twig/Autoloader.php';
Twig_Autoloader::register();
}
示例11: __construct
public function __construct($request, $response, $params = NULL)
{
parent::__construct($request, $response, $params);
$this->_db = Typecho_Db::get();
$this->_dir = '.' . __TYPECHO_PLUGIN_DIR__ . '/CommentToMail/';
$this->_set = Helper::options()->plugin('CommentToMail');
require_once $this->_dir . 'class.phpmailer.php';
$this->mail = new PHPMailer();
}
示例12: __construct
public function __construct($request, $response, $params = NULL)
{
parent::__construct($request, $response, $params);
$this->_db = Typecho_Db::get();
$this->_options = Helper::options()->plugin('WeChatHelper');
$this->_textTpl = "<xml>\n <ToUserName><![CDATA[%s]]></ToUserName>\n <FromUserName><![CDATA[%s]]></FromUserName>\n <CreateTime>%s</CreateTime>\n <MsgType><![CDATA[text]]></MsgType>\n <Content><![CDATA[%s]]></Content>\n <FuncFlag>0</FuncFlag>\n </xml>";
$this->_imageTpl = "<xml>\n <ToUserName><![CDATA[%s]]></ToUserName>\n <FromUserName><![CDATA[%s]]></FromUserName>\n <CreateTime>%s</CreateTime>\n <MsgType><![CDATA[news]]></MsgType>\n <ArticleCount>%s</ArticleCount>\n <Articles>%s</Articles>\n <FuncFlag>1</FuncFlag>\n </xml>";
$this->_itemTpl = "<item>\n <Title><![CDATA[%s]]></Title> \n <Description><![CDATA[%s]]></Description>\n <PicUrl><![CDATA[%s]]></PicUrl>\n <Url><![CDATA[%s]]></Url>\n </item>";
}
示例13: action
/**
*Action入口
*@return redirect
*/
public function action()
{
$this->db = Typecho_Db::get();
$this->prefix = $this->db->getPrefix();
$this->options = Typecho_Widget::widget('Widget_Options');
$this->on($this->request->is('do=clearAll'))->clearAll();
$this->on($this->request->is('do=deleteLog'))->deleteLog();
$referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 'javascript:history.back(-1);';
$this->response->redirect($referer);
}
示例14: action
public function action()
{
$this->db = Typecho_Db::get();
$this->options = Typecho_Widget::widget('Widget_Options');
$this->on($this->request->is('do=insert'))->insertLink();
$this->on($this->request->is('do=update'))->updateLink();
$this->on($this->request->is('do=delete'))->deleteLink();
$this->on($this->request->is('do=sort'))->sortLink();
$this->response->redirect($this->options->adminUrl);
}
示例15: optimize
public function optimize()
{
$db = Typecho_Db::get();
$config = $db->getConfig();
$tables = $db->fetchAll("SHOW TABLE STATUS FROM " . $config[0]->database);
foreach ($tables as $row) {
$result = $db->fetchAll('OPTIMIZE TABLE ' . $row['Name']);
}
$this->widget('Widget_Notice')->set(_t('数据库优化完成!'), 'success');
$this->response->goBack();
}