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


PHP ActiveRecord::size方法代码示例

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


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

示例1: getPages

 public function getPages()
 {
     $blog = new ActiveRecord();
     $num = $blog->size();
     $pages = $blog->pickout($num - 5, 5);
     $result = array();
     for ($i = 0; $i < 5; $i++) {
         $result[$i] = array('title' => $pages[4 - $i]->title, 'url' => "/?page={$pages[4 - $i]->pagenum}");
     }
     return $result;
 }
开发者ID:pakutoma,项目名称:pakutomablog,代码行数:11,代码来源:latestpages.php

示例2: ActiveRecord

<?php

require_once 'activerecord.php';
$ar = new ActiveRecord();
$ar->connectPdo('blogdb', 'blog', $_POST['username'], $_POST['password']);
$postid = $ar->size() + 1;
$ar->pagenum = $postid;
$ar->author = $_POST['username'];
$ar->date = date('Y/m/d');
$ar->title = $_POST['title'];
$ar->text = nl2br($_POST['text']);
try {
    $ar->save();
} catch (Exception $e) {
    echo $e->getMessage();
    return;
}
$ar->connectPdo('blogdb', 'categorytable', $_POST['username'], $_POST['password']);
$categories = explode(',', $_POST["category"]);
foreach ($categories as $category) {
    $ar->postid = $postid;
    $ar->category = $category;
    try {
        $ar->save();
    } catch (Exception $e) {
        echo $e->getMessage();
        $ar->connectPdo('blogdb', 'blog', $_POST['username'], $_POST['password']);
        $postid = $ar->size();
        $ar->delete($postid);
        return;
    }
开发者ID:pakutoma,项目名称:pakutomablog,代码行数:31,代码来源:post.php

示例3: Smarty

<?php

define('SMARTY_DIR', '/usr/share/php/smarty3/');
require_once 'activerecord.php';
require_once SMARTY_DIR . 'Smarty.class.php';
$smarty = new Smarty();
$smarty->template_dir = '/srv/smarty/templates';
$smarty->compile_dir = '/srv/smarty/templates_c';
$smarty->config_dir = '/srv/smarty/configs';
$smarty->cache_dir = '/srv/smarty/cache';
$blog = new ActiveRecord();
$blog->connectPdo('blogdb', 'blog', 'readonly', 'readonly');
$num = $blog->size();
$pages = $blog->pickout($num - 10, 10);
$items = array();
$category = new ActiveRecord();
$category->connectPdo('blogdb', 'categorytable', 'readonly', 'readonly');
$categories = $category->find($num - 2)->category;
for ($i = 0; $i < 10; $i++) {
    $categorystr = $category->find($num - (9 - $i))->category;
    $datetime = new DateTime($pages[9 - $i]->date);
    $items[$i] = array('title' => $pages[9 - $i]->title, 'link' => "http://pakutoma.pw/?page={$pages[9 - $i]->pagenum}", 'category' => $categorystr, 'description' => mb_substr(str_replace("\n", " ", strip_tags($pages[9 - $i]->text)), 0, 40) . '...', 'pubDate' => $datetime->format(DATE_RSS));
}
$smarty->assign('items', $items);
$smarty->display('rss.tpl');
开发者ID:pakutoma,项目名称:pakutomablog,代码行数:25,代码来源:rss.php

示例4: LatestPages

            $data = $archiveview->getPages($archive);
            if (!isset($data[0]->pagenum)) {
                echo "データが存在しません。";
                return;
            }
            $latest = new LatestPages();
            $category = new Category();
            $archive = new Archive();
            foreach (array_reverse($data) as $page) {
                $main[] = array('title' => $page->title, 'date' => $page->date, 'text' => mb_substr($page->text, 0, mb_strpos($page->text, "<br />")), 'pagenum' => $page->pagenum);
            }
            $smarty->assign('title', 'アーカイブ:' . $_GET['archive']);
        } else {
            $blog = new ActiveRecord();
            $blog->connectPdo('blogdb', 'blog', 'readonly', 'readonly');
            $data = $blog->find($blog->size());
            if (!isset($data->pagenum)) {
                echo "データが存在しません。";
                return;
            }
            $latest = new LatestPages();
            $category = new Category();
            $archive = new Archive();
            $main[] = array('title' => $data->title, 'date' => $data->date, 'text' => $data->text);
            $smarty->assign('prev', $blog->find($blog->size() - 1));
        }
    }
}
$smarty->assign('main', $main);
$smarty->assign('latest', $latest->getPages());
$smarty->assign('category', $category->getCategory());
开发者ID:pakutoma,项目名称:pakutomablog,代码行数:31,代码来源:index.php


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