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


PHP Record::tableFromClass方法代码示例

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


在下文中一共展示了Record::tableFromClass方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getTotal

 public static function getTotal()
 {
     $tablename = Record::tableFromClass('Article');
     $sql = "SELECT COUNT(id) AS total FROM {$tablename} WHERE type='post'";
     self::$__CONN__->query($sql);
     return self::$__CONN__->last_result[0]->total;
 }
开发者ID:chaobj001,项目名称:tt,代码行数:7,代码来源:Cache.class.php

示例2: createAction

 public function createAction()
 {
     global $tpl;
     set_time_limit(100);
     //删除data/chache目录
     $path = DATA_DIR . 'cache/';
     //缓存目录
     if ($handle = opendir($path)) {
         while (false !== ($file = readdir($handle))) {
             if ($file != "." && $file != "..") {
                 //$files[] = $file;
                 @unlink($path . $file);
             }
         }
         closedir($handle);
     }
     //删除首页
     del_cache();
     //文章
     $total = Cache::getTotal();
     $start = 0;
     $limit = 20;
     $start_id = 0;
     $i = 0;
     $tablename_content = Record::tableFromClass('Article');
     $tablename_contentpart = Record::tableFromClass('ContentPart');
     $previous = null;
     while ($i < $total) {
         $sql = "select * from {$tablename_content} where type='post' and id > {$start_id} order by id asc limit {$limit}";
         Record::$__CONN__->query($sql);
         $articles = array();
         $articles = Record::$__CONN__->last_result;
         if (is_array($articles) && count($articles) > 0) {
             foreach ($articles as $k => $data) {
                 $article = new Article(get_object_vars($data));
                 //上一页
                 $previous = isset($previous) ? $previous : '';
                 $tpl->assign('previous', $previous);
                 $previous = $article;
                 //下一页
                 if (isset($articles[$k + 1])) {
                     //$next = new Article(get_object_vars($articles[$k+1]));
                     $next = $articles[$k + 1];
                 } else {
                     $next = $article->next();
                 }
                 $tpl->assign('next', $next);
                 $content_part = ContentPart::findById($article->id);
                 $article->content = processContent($content_part->content);
                 $article->tags = isset($this->cahce_tags[$article->id]) ? $this->cahce_tags[$article->id] : array();
                 $article->category = isset($this->cahce_categories[$article->cid]) ? $this->cahce_categories[$article->cid]['name'] : '无分类';
                 $article->category_slug = isset($this->cahce_categories[$article->cid]) ? $this->cahce_categories[$article->cid]['slug'] : 'uncategory';
                 $this->createHtml($article);
                 if ($k == $limit - 1) {
                     $start_id = $article->id;
                 }
             }
         }
         $i += $limit;
     }
     //while
     flush();
     echo 'create cache over!';
     echo '<a href="index.php">Index</a>';
 }
开发者ID:chaobj001,项目名称:tt,代码行数:65,代码来源:AdminCacheController.class.php

示例3: batch_moveAction

 /**
  * 批量移动文章
  * @param <type> $args
  */
 public function batch_moveAction($args = null)
 {
     //move update cid
     $post_checked = isset($_POST['checked']) ? $_POST['checked'] : null;
     $newcid = isset($_POST['newcid']) ? $_POST['newcid'] : null;
     if (is_array($post_checked) && count($post_checked) > 0) {
         $id_arr = array();
         foreach ($post_checked as $val) {
             $data = unserialize(base64_decode($val));
             if ($data->cid != $newcid) {
                 $id_arr[] = $data->id;
                 //更新分类统计
                 //                    $c2 = new Category('id', $data->cid);
                 //                    $c2->count--;
                 //                    $c2->save();
                 $tablename = Record::tableFromClass('Category');
                 $sql = "UPDATE {$tablename} SET count=count-1 WHERE id = '{$data->cid}'";
                 Record::$__CONN__->query($sql);
             }
         }
         //sql
         Article::moveIds($id_arr, $newcid);
     }
     //更新文章分类统计
     $c1 = new Category('id', $newcid);
     $c1->count = $c1->count + count($id_arr);
     $c1->save();
     del_cache();
     go_redirect('index.php?job=admin_article');
 }
开发者ID:chaobj001,项目名称:tt,代码行数:34,代码来源:AdminArticleController.class.php


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