本文整理汇总了PHP中Typecho_Db类的典型用法代码示例。如果您正苦于以下问题:PHP Typecho_Db类的具体用法?PHP Typecho_Db怎么用?PHP Typecho_Db使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Typecho_Db类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* 初始化函数
*
* @access public
* @return void
*/
public function execute()
{
/** 设置参数默认值 */
$this->parameter->setDefault('format=Y-m&type=month&limit=0');
$resource = $this->db->query($this->db->select('created')->from('table.contents')->where('type = ?', 'post')->where('table.contents.status = ?', 'publish')->where('table.contents.created < ?', $this->options->gmtTime)->order('table.contents.created', Typecho_Db::SORT_DESC));
$offset = $this->options->timezone - $this->options->serverTimezone;
$result = array();
while ($post = $this->db->fetchRow($resource)) {
$timeStamp = $post['created'] + $offset;
$date = date($this->parameter->format, $timeStamp);
if (isset($result[$date])) {
$result[$date]['count']++;
} else {
$result[$date]['year'] = date('Y', $timeStamp);
$result[$date]['month'] = date('m', $timeStamp);
$result[$date]['day'] = date('d', $timeStamp);
$result[$date]['date'] = $date;
$result[$date]['count'] = 1;
}
}
if ($this->parameter->limit > 0) {
$result = array_slice($result, 0, $this->parameter->limit);
}
foreach ($result as $row) {
$row['permalink'] = Typecho_Router::url('archive_' . $this->parameter->type, $row, $this->widget('Widget_Options')->index);
$this->push($row);
}
}
开发者ID:r0ker,项目名称:hctf2015-all-problems,代码行数:34,代码来源:Date.php
示例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;
}
开发者ID:m4html,项目名称:typecho-theme-Twentyfifteen,代码行数:28,代码来源:functions.php
示例3: 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>';
}
开发者ID:nbdarling,项目名称:typechoi7-master,代码行数:32,代码来源:sidebar.php
示例4: __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');
}
开发者ID:duxiangfei,项目名称:plugins,代码行数:7,代码来源:Action.php
示例5: 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;
}
开发者ID:duxiangfei,项目名称:plugins,代码行数:30,代码来源:Action.php
示例6: __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;
}
}
开发者ID:ClayMoreBoy,项目名称:typecho-plugin-Access,代码行数:26,代码来源:Access.php
示例7: 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' => '你已经点赞过了!'));
}
开发者ID:jiangmuzi,项目名称:TeStat,代码行数:26,代码来源:Action.php
示例8: 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('收藏出错!')));
}
}
开发者ID:dccecc,项目名称:typecho,代码行数:27,代码来源:Action.php
示例9: __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();
}
开发者ID:jiusanzhou,项目名称:spacms,代码行数:9,代码来源:Action.php
示例10: __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();
}
开发者ID:daixl2010,项目名称:Typecho-Nesoft-Theme,代码行数:9,代码来源:Action.php
示例11: __construct
public function __construct($request, $response, $params = NULL)
{
parent::__construct($request, $response, $params);
/** 初始化数据库 */
$this->db = Typecho_Db::get();
/** 初始化常用组件 */
$this->options = $this->widget('Widget_Options');
$this->_time = new Typecho_Date($this->options->gmtTime);
}
开发者ID:dccecc,项目名称:typecho,代码行数:9,代码来源:Verify.php
示例12: __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->options = $this->widget('Widget_Options');
$this->user = $this->widget('Widget_User');
}
开发者ID:menmenweiwei,项目名称:blog,代码行数:18,代码来源:Abstract.php
示例13: __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>";
}
开发者ID:duxiangfei,项目名称:plugins,代码行数:9,代码来源:Action.php
示例14: 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);
}
开发者ID:hongweipeng,项目名称:cool_blog,代码行数:14,代码来源:Action.php
示例15: 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);
}
开发者ID:vergil-lai,项目名称:Devel-May-Coding,代码行数:10,代码来源:Action.php
示例16: 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();
}
开发者ID:duxiangfei,项目名称:plugins,代码行数:11,代码来源:Action.php
示例17: topcategory
function topcategory($category)
{
$db = Typecho_Db::get();
$prefix = $db->getPrefix();
$rs = $db->fetchRow($db->select()->from($prefix . 'metas')->where('slug = ?', $category)->limit(1));
if (isset($rs['parent']) && $rs['parent'] == 0) {
return $rs['slug'];
} elseif (isset($rs['parent'])) {
$rs2 = $db->fetchRow($db->select()->from($prefix . 'metas')->where('mid = ?', $rs['parent'])->limit(1));
return $rs2['slug'];
}
}
开发者ID:zhouxiaohui0327,项目名称:ups,代码行数:12,代码来源:functions.php
示例18: action
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=insert'))->insertLink();
$this->on($this->request->is('do=addhanson'))->addHanSonBlog();
$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);
}
开发者ID:HanSon,项目名称:Links_for_Material_Theme,代码行数:12,代码来源:Action.php
示例19: thePrev
/**
* 显示上一篇
*
* @access public
* @param string $default 如果没有上一篇, 显示的默认文字
* @return void
*/
function thePrev($widget, $word = '上一篇', $default = NULL)
{
$db = Typecho_Db::get();
$sql = $db->select()->from('table.contents')->where('table.contents.created < ?', $widget->created)->where('table.contents.status = ?', 'publish')->where('table.contents.type = ?', $widget->type)->where('table.contents.password IS NULL')->order('table.contents.created', Typecho_Db::SORT_DESC)->limit(1);
$content = $db->fetchRow($sql);
if ($content) {
$content = $widget->filter($content);
$link = '<a href="' . $content['permalink'] . '" id="article-nav-older" class="article-nav-link-wrap" title="' . $content['title'] . '">' . '<div class="article-nav-title">' . $content['title'] . '</div><strong class="article-nav-caption">></strong>' . '</a>';
echo $link;
} else {
echo $default;
}
}
开发者ID:wujunze,项目名称:wujunze.com,代码行数:20,代码来源:functions.php
示例20: init
public function init($option)
{
$this->db = Typecho_Db::get();
$prefix = $this->db->getPrefix();
$table_name = $prefix . 'cache';
$sql_detect = "SHOW TABLES LIKE '%" . $table_name . "%'";
if (count($this->db->fetchAll($sql_detect)) == 0) {
$this->install_db();
} else {
// 用访问触发缓存过期
$this->db->query($this->db->delete('table.cache')->where('time <= ?', time() - $this->expire));
}
}
开发者ID:wujunze,项目名称:wujunze.com,代码行数:13,代码来源:typecho_mysql.class.php
注:本文中的Typecho_Db类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论