当前位置: 首页>>代码示例>>PHP>>正文


PHP Typecho_Db::query方法代码示例

本文整理汇总了PHP中Typecho_Db::query方法的典型用法代码示例。如果您正苦于以下问题:PHP Typecho_Db::query方法的具体用法?PHP Typecho_Db::query怎么用?PHP Typecho_Db::query使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Typecho_Db的用法示例。


在下文中一共展示了Typecho_Db::query方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: execute

 /**
  * 执行函数
  *
  * @access public
  * @return void
  */
 public function execute()
 {
     if ($this->hasLogin()) {
         $rows = $this->db->fetchAll($this->db->select()->from('table.options')->where('user = ?', $this->_user['uid']));
         $this->push($this->_user);
         foreach ($rows as $row) {
             $this->options->__set($row['name'], $row['value']);
         }
         //更新最后活动时间
         $this->db->query($this->db->update('table.users')->rows(array('activated' => $this->options->gmtTime))->where('uid = ?', $this->_user['uid']));
     }
 }
开发者ID:javanprettycool,项目名称:jblog,代码行数:18,代码来源:User.php

示例3: login

 /**
  * 以用户名和密码登录
  *
  * @access public
  * @param string $name 用户名
  * @param string $password 密码
  * @param boolean $temporarily 是否为临时登录
  * @param integer $expire 过期时间
  * @return boolean
  */
 public function login($name, $password, $temporarily = false, $expire = 0)
 {
     //插件接口
     $result = $this->pluginHandle()->trigger($loginPluggable)->login($name, $password, $temporarily, $expire);
     if ($loginPluggable) {
         return $result;
     }
     /** 开始验证用户 **/
     $user = $this->db->fetchRow($this->db->select()->from('table.users')->where('name = ?', $name)->limit(1));
     $hashValidate = $this->pluginHandle()->trigger($hashPluggable)->hashValidate($password, $user['password']);
     if (!$hashPluggable) {
         $hashValidate = Typecho_Common::hashValidate($password, $user['password']);
     }
     if ($user && $hashValidate) {
         if (!$temporarily) {
             $authCode = sha1(Typecho_Common::randString(20));
             $user['authCode'] = $authCode;
             Typecho_Cookie::set('__typecho_uid', $user['uid'], $expire, $this->options->siteUrl);
             Typecho_Cookie::set('__typecho_authCode', Typecho_Common::hash($authCode), $expire, $this->options->siteUrl);
             //更新最后登录时间以及验证码
             $this->db->query($this->db->update('table.users')->expression('logged', 'activated')->rows(array('authCode' => $authCode))->where('uid = ?', $user['uid']));
         }
         /** 压入数据 */
         $this->push($user);
         $this->_hasLogin = true;
         $this->pluginHandle()->loginSucceed($this, $name, $password, $temporarily, $expire);
         return true;
     }
     $this->pluginHandle()->loginFail($this, $name, $password, $temporarily, $expire);
     return false;
 }
开发者ID:raindali,项目名称:express,代码行数:41,代码来源:User.php

示例4: execute

 /**
  * 执行函数
  *
  * @access public
  * @return void
  */
 public function execute()
 {
     $this->db->fetchAll($this->db->select()->from('table.options')->where('user = 0'), array($this, 'push'));
     /** 支持皮肤变量重载 */
     if (!empty($this->row['theme:' . $this->row['theme']])) {
         $themeOptions = NULL;
         /** 解析变量 */
         if ($themeOptions = unserialize($this->row['theme:' . $this->row['theme']])) {
             /** 覆盖变量 */
             $this->row = array_merge($this->row, $themeOptions);
         }
     }
     $this->stack[] =& $this->row;
     /** 初始化站点信息 */
     $this->siteUrl = Typecho_Common::url(NULL, $this->siteUrl);
     $this->plugins = unserialize($this->plugins);
     /** 增加对SSL连接的支持 */
     if ($this->request->isSecure() && 0 === strpos($this->siteUrl, 'http://')) {
         $this->siteUrl = substr_replace($this->siteUrl, 'https', 0, 4);
     }
     /** 自动初始化路由表 */
     $this->routingTable = unserialize($this->routingTable);
     if (!isset($this->routingTable[0])) {
         /** 解析路由并缓存 */
         $parser = new Typecho_Router_Parser($this->routingTable);
         $parsedRoutingTable = $parser->parse();
         $this->routingTable = array_merge(array($parsedRoutingTable), $this->routingTable);
         $this->db->query($this->db->update('table.options')->rows(array('value' => serialize($this->routingTable)))->where('name = ?', 'routingTable'));
     }
 }
开发者ID:raindali,项目名称:express,代码行数:36,代码来源:Options.php

示例5: execute

 /**
  * 执行函数
  *
  * @access public
  * @return void
  */
 public function execute()
 {
     $this->db->fetchAll($this->db->select()->from('table.options')->where('user = 0'), array($this, 'push'));
     /** 支持皮肤变量重载 */
     if (!empty($this->row['theme:' . $this->row['theme']])) {
         $themeOptions = NULL;
         /** 解析变量 */
         if ($themeOptions = unserialize($this->row['theme:' . $this->row['theme']])) {
             /** 覆盖变量 */
             $this->row = array_merge($this->row, $themeOptions);
         }
     }
     $this->stack[] =& $this->row;
     /** 初始化站点信息 */
     if (defined('__TYPECHO_SITE_URL__')) {
         $this->siteUrl = __TYPECHO_SITE_URL__;
     }
     $this->originalSiteUrl = $this->siteUrl;
     $this->siteUrl = Typecho_Common::url(NULL, $this->siteUrl);
     $this->plugins = unserialize($this->plugins);
     /** 动态判断皮肤目录 */
     $this->theme = is_dir($this->themeFile($this->theme)) ? $this->theme : 'default';
     /** 动态获取根目录 */
     $this->rootUrl = $this->request->getRequestRoot();
     if (defined('__TYPECHO_ADMIN__')) {
         $adminDir = '/' . trim(defined('__TYPECHO_ADMIN_DIR__') ? __TYPECHO_ADMIN_DIR__ : '/admin/', '/');
         $this->rootUrl = substr($this->rootUrl, 0, -strlen($adminDir));
     }
     /** 增加对SSL连接的支持 */
     if ($this->request->isSecure() && 0 === strpos($this->siteUrl, 'http://')) {
         $this->siteUrl = substr_replace($this->siteUrl, 'https', 0, 4);
     }
     //$router = include __TYPECHO_ROOT_DIR__.'/var/config.php';
     //$parser = new Typecho_Router_Parser($router);
     //$parsedRoutingTable = $parser->parse();
     //$this->routingTable = array($parsedRoutingTable);
     /** 自动初始化路由表 */
     $this->routingTable = unserialize($this->routingTable);
     if (!isset($this->routingTable[0])) {
         /** 解析路由并缓存 */
         $parser = new Typecho_Router_Parser($this->routingTable);
         $parsedRoutingTable = $parser->parse();
         $this->routingTable = array_merge(array($parsedRoutingTable), $this->routingTable);
         $this->db->query($this->db->update('table.options')->rows(array('value' => serialize($this->routingTable)))->where('name = ?', 'routingTable'));
     }
 }
开发者ID:veryer,项目名称:sisome,代码行数:52,代码来源:Options.php

示例6: login

 /**
  * 以用户名和密码登录
  *
  * @access public
  * @param string $name 用户名
  * @param string $password 密码
  * @param boolean $temporarily 是否为临时登录
  * @param integer $expire 过期时间
  * @return boolean
  */
 public function login($name, $password, $temporarily = false, $expire = 0)
 {
     //插件接口
     $result = $this->pluginHandle()->trigger($loginPluggable)->login($name, $password, $temporarily, $expire);
     if ($loginPluggable) {
         return $result;
     }
     /** 开始验证用户 **/
     $user = $this->db->fetchRow($this->db->select()->from('table.users')->where((strpos($name, '@') ? 'mail' : 'name') . ' = ?', $name)->limit(1));
     if (empty($user)) {
         return false;
     }
     $hashValidate = $this->pluginHandle()->trigger($hashPluggable)->hashValidate($password, $user['password']);
     if (!$hashPluggable) {
         if ('$P$' == substr($user['password'], 0, 3)) {
             $hasher = new PasswordHash(8, true);
             $hashValidate = $hasher->CheckPassword($password, $user['password']);
         } else {
             $hashValidate = Typecho_Common::hashValidate($password, $user['password']);
         }
     }
     if ($user && $hashValidate) {
         if (!$temporarily) {
             $authCode = function_exists('openssl_random_pseudo_bytes') ? bin2hex(openssl_random_pseudo_bytes(16)) : sha1(Typecho_Common::randString(20));
             $user['authCode'] = $authCode;
             Typecho_Cookie::set('__typecho_uid', $user['uid'], $expire);
             Typecho_Cookie::set('__typecho_authCode', Typecho_Common::hash($authCode), $expire);
             //更新最后登录时间以及验证码
             $this->db->query($this->db->update('table.users')->expression('logged', 'activated')->rows(array('authCode' => $authCode))->where('uid = ?', $user['uid']));
         }
         /** 压入数据 */
         $this->push($user);
         $this->_hasLogin = true;
         $this->pluginHandle()->loginSucceed($this, $name, $password, $temporarily, $expire);
         return true;
     }
     $this->pluginHandle()->loginFail($this, $name, $password, $temporarily, $expire);
     return false;
 }
开发者ID:r0ker,项目名称:hctf2015-all-problems,代码行数:49,代码来源:User.php

示例7: v0_8r10_3_8

 /**
  * 升级至10.3.8
  *
  * @access public
  * @param Typecho_Db $db 数据库对象
  * @param Typecho_Widget $options 全局信息组件
  * @return void
  */
 public static function v0_8r10_3_8($db, $options)
 {
     /** 删除无用选项 */
     $db->query($db->delete('table.options')->where('name = ?', 'commentsAvatarSize'));
 }
开发者ID:menmenweiwei,项目名称:blog,代码行数:13,代码来源:Upgrade.php

示例8: doImport

 public function doImport()
 {
     $options = $this->widget('Widget_Options');
     $dbConfig = $options->plugin('WordpressToTypecho');
     /** 初始化一个db */
     if (Typecho_Db_Adapter_Mysql::isAvailable()) {
         $db = new Typecho_Db('Mysql', $dbConfig->prefix);
     } else {
         $db = new Typecho_Db('Pdo_Mysql', $dbConfig->prefix);
     }
     /** 只读即可 */
     $db->addServer(array('host' => $dbConfig->host, 'user' => $dbConfig->user, 'password' => $dbConfig->password, 'charset' => 'utf8', 'port' => $dbConfig->port, 'database' => $dbConfig->database), Typecho_Db::READ);
     /** 删除当前内容 */
     $masterDb = Typecho_Db::get();
     $this->widget('Widget_Abstract_Contents')->to($contents)->delete($masterDb->sql()->where('1 = 1'));
     $this->widget('Widget_Abstract_Comments')->to($comments)->delete($masterDb->sql()->where('1 = 1'));
     $this->widget('Widget_Abstract_Metas')->to($metas)->delete($masterDb->sql()->where('1 = 1'));
     $this->widget('Widget_Contents_Post_Edit')->to($edit);
     $masterDb->query($masterDb->delete('table.relationships')->where('1 = 1'));
     $userId = $this->widget('Widget_User')->uid;
     /** 获取时区偏移 */
     $gmtOffset = idate('Z');
     /** 转换全局变量 */
     /** 
             $rows = $db->fetchAll($db->select()->from('table.statics'));
             $static = array();
             foreach ($rows as $row) {
                 $static[$row['static_name']] = $row['static_value'];
             }*/
     /** 转换文件 */
     /**$files = $db->fetchAll($db->select()->from('table.files'));
        if (!is_dir(__TYPECHO_ROOT_DIR__ . '/usr/uploads/')) {
            mkdir(__TYPECHO_ROOT_DIR__ . '/usr/uploads/', 0766);
        }
        
        $pattern = array();
        $replace = array();
        foreach ($files as $file) {
            $path = __TYPECHO_ROOT_DIR__ . '/data/upload/' . substr($file['file_guid'], 0, 2) . '/' .
            substr($file['file_guid'], 2, 2) . '/' . $file['file_guid'];
            
            if (is_file($path)) {
                $file['file_time'] = empty($file['file_time']) ? $options->gmtTime : $file['file_time'];
                $year = idate('Y', $file['file_time']);
                $month = idate('m', $file['file_time']);
                $day = idate('d', $file['file_time']);
                
                if (!is_dir(__TYPECHO_ROOT_DIR__ . "/usr/uploads/{$year}")) {
                    mkdir(__TYPECHO_ROOT_DIR__ . "/usr/uploads/{$year}", 0766);
                }
                
                if (!is_dir(__TYPECHO_ROOT_DIR__ . "/usr/uploads/{$year}/{$month}")) {
                    mkdir(__TYPECHO_ROOT_DIR__ . "/usr/uploads/{$year}/{$month}", 0766);
                }
                
                if (!is_dir(__TYPECHO_ROOT_DIR__ . "/usr/uploads/{$year}/{$month}/{$day}")) {
                    mkdir(__TYPECHO_ROOT_DIR__ . "/usr/uploads/{$year}/{$month}/{$day}", 0766);
                }
                
                $parts = explode('.', $file['file_name']);
                $ext = array_pop($parts);
                copy($path, __TYPECHO_ROOT_DIR__ . "/usr/uploads/{$year}/{$month}/{$day}/{$file['file_id']}.{$ext}");
                
                $new = Typecho_Common::url("/usr/uploads/{$year}/{$month}/{$day}/{$file['file_id']}.{$ext}", $options->siteUrl);
                $old = Typecho_Common::url("/res/{$file['file_id']}/{$file['file_name']}", $static['siteurl'] . '/index.php');
                $pattern[] = '/' . str_replace('\/index\.php', '(\/index\.php)?', preg_quote($old, '/')) . '/is';
                $replace[] = $new;
            }
        }
        */
     /** 转换评论 */
     $i = 1;
     while (true) {
         $result = $db->query($db->select()->from('table.comments')->order('comment_ID', Typecho_Db::SORT_ASC)->page($i, 100));
         $j = 0;
         while ($row = $db->fetchRow($result)) {
             $status = $row['comment_approved'];
             if ('spam' == $row['comment_approved']) {
                 $status = 'spam';
             } else {
                 if ('0' == $row['comment_approved']) {
                     $status = 'waiting';
                 } else {
                     $status = 'approved';
                 }
             }
             $row['comment_content'] = preg_replace(array("/\\s*<p>/is", "/\\s*<\\/p>\\s*/is", "/\\s*<br\\s*\\/>\\s*/is", "/\\s*<(div|blockquote|pre|table|ol|ul)>/is", "/<\\/(div|blockquote|pre|table|ol|ul)>\\s*/is"), array('', "\n\n", "\n", "\n\n<\\1>", "</\\1>\n\n"), $row['comment_content']);
             $comments->insert(array('coid' => $row['comment_ID'], 'cid' => $row['comment_post_ID'], 'created' => strtotime($row['comment_date_gmt']) + $gmtOffset, 'author' => $row['comment_author'], 'authorId' => $row['user_id'], 'ownerId' => 1, 'mail' => $row['comment_author_email'], 'url' => $row['comment_author_url'], 'ip' => $row['comment_author_IP'], 'agent' => $row['comment_agent'], 'text' => $row['comment_content'], 'type' => empty($row['comment_type']) ? 'comment' : $row['comment_type'], 'status' => $status, 'parent' => $row['comment_parent']));
             $j++;
             unset($row);
         }
         if ($j < 100) {
             break;
         }
         $i++;
         unset($result);
     }
     /** 转换Wordpress的term_taxonomy表 */
     $terms = $db->fetchAll($db->select()->from('table.term_taxonomy')->join('table.terms', 'table.term_taxonomy.term_id = table.terms.term_id')->where('taxonomy = ? OR taxonomy = ?', 'category', 'post_tag'));
     foreach ($terms as $term) {
//.........这里部分代码省略.........
开发者ID:luobenyu,项目名称:plugins,代码行数:101,代码来源:Action.php

示例9: foreach

     $dbConfig[strtolower(substr($key, 2))] = $val;
 }
 // 在特殊服务器上的特殊安装过程处理
 if (_r('config')) {
     $replace = array_keys($dbConfig);
     foreach ($replace as &$key) {
         $key = '{' . $key . '}';
     }
     $config = str_replace($replace, array_values($dbConfig), _r('config'));
 }
 if (!isset($config) && $success && !_r('created')) {
     $installDb = new Typecho_Db($adapter, _r('dbPrefix'));
     $installDb->addServer($dbConfig, Typecho_Db::READ | Typecho_Db::WRITE);
     /** 检测数据库配置 */
     try {
         $installDb->query('SELECT 1=1');
     } catch (Typecho_Db_Adapter_Exception $e) {
         $success = false;
         echo '<p class="message error">' . _t('对不起,无法连接数据库,请先检查数据库配置再继续进行安装') . '</p>';
     } catch (Typecho_Db_Exception $e) {
         $success = false;
         echo '<p class="message error">' . _t('安装程序捕捉到以下错误: " %s ". 程序被终止, 请检查您的配置信息.', $e->getMessage()) . '</p>';
     }
 }
 if ($success) {
     Typecho_Cookie::set('__typecho_config', base64_encode(serialize(array_merge(array('prefix' => _r('dbPrefix'), 'userName' => _r('userName'), 'userPassword' => _r('userPassword'), 'userMail' => _r('userMail'), 'adapter' => $adapter, 'siteUrl' => _r('userUrl')), $dbConfig))));
     if (_r('created')) {
         header('Location: ./install.php?start');
         exit;
     }
     /** 初始化配置文件 */
开发者ID:menmenweiwei,项目名称:blog,代码行数:31,代码来源:install.php

示例10: array

             }
         }
     }
 }
 if ($success) {
     $installDb = new Typecho_Db($adapter, _r('dbPrefix'));
     $_dbConfig = _rFrom('dbHost', 'dbUser', 'dbPassword', 'dbCharset', 'dbPort', 'dbDatabase', 'dbFile', 'dbDsn');
     $_dbConfig = array_filter($_dbConfig);
     $dbConfig = array();
     foreach ($_dbConfig as $key => $val) {
         $dbConfig[strtolower(substr($key, 2))] = $val;
     }
     $installDb->addServer($dbConfig, Typecho_Db::READ | Typecho_Db::WRITE);
     /** 检测数据库配置 */
     try {
         $installDb->query('SELECT 1=1');
     } catch (Typecho_Db_Adapter_Exception $e) {
         $success = false;
         echo '<p class="message error typecho-radius-topleft typecho-radius-topright typecho-radius-bottomleft typecho-radius-bottomright">' . _t('对不起,无法连接数据库,请先检查数据库配置再继续进行安装') . '</p>';
     } catch (Typecho_Db_Exception $e) {
         $success = false;
         echo '<p class="message error typecho-radius-topleft typecho-radius-topright typecho-radius-bottomleft typecho-radius-bottomright">' . _t('安装程序捕捉到以下错误: "%s". 程序被终止, 请检查您的配置信息.', $e->getMessage()) . '</p>';
     }
 }
 if ($success) {
     /** 初始化配置文件 */
     $lines = array_slice(file(__FILE__), 0, 52);
     $lines[] = "\n/** 定义数据库参数 */\n\$db = new Typecho_Db('{$adapter}', '" . _r('dbPrefix') . "');\n\$db->addServer(" . var_export($dbConfig, true) . ", Typecho_Db::READ | Typecho_Db::WRITE);\nTypecho_Db::set(\$db);\n";
     file_put_contents('./config.inc.php', implode('', $lines));
     try {
         /** 初始化数据库结构 */
开发者ID:raindali,项目名称:express,代码行数:31,代码来源:install.php

示例11: doImport

 public function doImport()
 {
     /* 获取配置 */
     $options = $this->widget('Widget_Options');
     $dbConfig = $options->plugin('EmlogToTypecho');
     /* 初始化一个db */
     if (Typecho_Db_Adapter_Mysql::isAvailable()) {
         $db = new Typecho_Db('Mysql', $dbConfig->prefix);
     } else {
         $db = new Typecho_Db('Pdo_Mysql', $dbConfig->prefix);
     }
     /* 只读即可 */
     $db->addServer(array('host' => $dbConfig->host, 'user' => $dbConfig->user, 'password' => $dbConfig->password, 'charset' => 'utf8', 'port' => $dbConfig->port, 'database' => $dbConfig->database), Typecho_Db::READ);
     /* 删除当前内容 */
     $masterDb = Typecho_Db::get();
     $this->widget('Widget_Abstract_Contents')->to($contents)->delete($masterDb->sql()->where('1 = 1'));
     $this->widget('Widget_Abstract_Comments')->to($comments)->delete($masterDb->sql()->where('1 = 1'));
     $this->widget('Widget_Contents_Post_Edit')->to($edit);
     $masterDb->query($masterDb->delete('table.relationships')->where('1 = 1'));
     /* 获取 emlog 管理员信息 */
     $emUser = $db->fetchRow($db->query($db->select()->from('table.user')));
     $emUsername = $emUser['username'];
     $emNickname = $emUser['nickname'];
     /* 转换评论表 */
     $i = 1;
     while (true) {
         $result = $db->query($db->select()->from('table.comment')->order('cid', Typecho_Db::SORT_ASC)->page($i, 100));
         $j = 0;
         while ($row = $db->fetchRow($result)) {
             $status = '';
             if ('y' == $row['hide']) {
                 $status = 'waiting';
             } else {
                 $status = 'approved';
             }
             if ($emUsername == $row['poster'] || $emNickname == $row['poster']) {
                 $authorId = 1;
             } else {
                 $authorId = 0;
             }
             $row['comment'] = preg_replace(array("/\\s*<p>/is", "/\\s*<\\/p>\\s*/is", "/\\s*<br\\s*\\/>\\s*/is", "/\\s*<(div|blockquote|pre|table|ol|ul)>/is", "/<\\/(div|blockquote|pre|table|ol|ul)>\\s*/is"), array('', "\n\n", "\n", "\n\n<\\1>", "</\\1>\n\n"), $row['comment']);
             $comments->insert(array('coid' => $row['cid'], 'cid' => $row['gid'], 'created' => $row['date'], 'author' => $row['poster'], 'authorId' => $authorId, 'ownerId' => 1, 'mail' => $row['mail'], 'url' => $row['url'], 'ip' => $row['ip'], 'agent' => NULL, 'text' => $row['comment'], 'type' => 'comment', 'status' => $status, 'parent' => $row['pid']));
             $j++;
             unset($row);
         }
         if ($j < 100) {
             break;
         }
         $i++;
         unset($result);
     }
     /* 转换文章表 */
     $i = 1;
     while (true) {
         $result = $db->query($db->select()->from('table.blog')->order('gid', Typecho_Db::SORT_ASC)->page($i, 100));
         $j = 0;
         while ($row = $db->fetchRow($result)) {
             $type = '';
             if ('page' == $row['type']) {
                 $type = 'page';
             } else {
                 if ('y' == $row['hide']) {
                     $type = 'post_draft';
                 } else {
                     $type = 'post';
                 }
             }
             $contents->insert(array('cid' => $row['gid'], 'title' => $row['title'], 'slug' => Typecho_Common::slugName(urldecode($row['alias']), $row['gid']), 'created' => $row['date'], 'modified' => $row['date'], 'text' => $row['content'], 'order' => 0, 'authorId' => $row['author'], 'template' => NULL, 'type' => $type, 'status' => 'publish', 'password' => $row['password'], 'commentsNum' => $row['comnum'], 'allowComment' => 'n' == $row['allow_remark'] ? '0' : '1', 'allowPing' => 0, 'allowFeed' => '1'));
             $j++;
             unset($row);
         }
         if ($j < 100) {
             break;
         }
         $i++;
         unset($result);
     }
     /* 转换 metas 表 */
     $sorts = $db->fetchAll($db->select()->from('table.sort'));
     foreach ($sorts as $sort) {
         $blogs = $db->fetchAll($db->select()->from('table.blog')->where('sortid = ?', $sort['sid']));
         $masterDb->query($masterDb->insert('table.metas')->rows(array('mid' => $sort['sid'] + 1, 'name' => $sort['sortname'], 'slug' => $sort['alias'], 'type' => 'category', 'description' => $sort['description'], 'count' => count($blogs), 'parent' => 0 != $sort['pid'] ? $sort['pid'] + 1 : 0)));
     }
     unset($sorts);
     $emtags = $db->fetchAll($db->select()->from('table.tag'));
     foreach ($emtags as $emtag) {
         $gid = trim($emtag['gid'], ',');
         $gids = explode(',', $gid);
         $masterDb->query($masterDb->insert('table.metas')->rows(array('name' => $emtag['tagname'], 'slug' => Typecho_Common::slugName($emtag['tagname']), 'type' => 'tag', 'description' => NULL, 'count' => count($gids))));
     }
     /* 转换关系表 */
     $emblogs = $db->fetchAll($db->select()->from('table.blog'));
     foreach ($emblogs as $emblog) {
         $masterDb->query($masterDb->insert('table.relationships')->rows(array('cid' => $emblog['gid'], 'mid' => -1 == $emblog['sortid'] ? 1 : $emblog['sortid'] + 1)));
     }
     unset($emblogs);
     $tags = $masterDb->fetchAll($masterDb->select()->from('table.metas')->where('type = ?', 'tag'));
     foreach ($tags as $tag) {
         foreach ($emtags as $emtag) {
             if ($tag['name'] == $emtag['tagname']) {
//.........这里部分代码省略.........
开发者ID:duxiangfei,项目名称:plugins,代码行数:101,代码来源:Action.php


注:本文中的Typecho_Db::query方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。