本文整理汇总了PHP中Article::count方法的典型用法代码示例。如果您正苦于以下问题:PHP Article::count方法的具体用法?PHP Article::count怎么用?PHP Article::count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Article
的用法示例。
在下文中一共展示了Article::count方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: home
public function home()
{
var_dump(Article::count());
$data = ['title' => '你是谁??', 'email' => '1@baiducom'];
$validator = $this->validate($data, ['title' => 'required|numeric|integer|min:3|max:4', 'email' => 'required|email']);
if (!$validator->success) {
foreach ($validator->errors as $error) {
echo $error . '<br>';
}
}
Log::debug('First Debug Info.');
/*
// mail sample
Mail::to('foo@bar.io')->from('bar@foo.io')
->title('Foo Bar')
->content('<h1>Hello~~</h1>')
->send();
// redis sample
Redis::set('key','value',3000,'ms');
echo Redis::get('key');
*/
// return View
return View::make('home')->with('article', Article::first())->withTitle('TinyLara :-D')->withFooBar('foo_bar');
// return String
return 'Hello TinyLara!';
// or you can return Nothing.
}
示例2: index
public function index($offset = 0)
{
$columns = array();
$configs = array($this->get_class(), '%s');
$conditions = conditions($columns, $configs);
Article::addConditions($conditions, 'is_visibled = ? AND destroy_user_id IS NULL', Article::IS_VISIBLED);
$limit = 7;
$total = Article::count(array('conditions' => $conditions));
$offset = $offset < $total ? $offset : 0;
$this->load->library('pagination');
$pagination = $this->pagination->initialize(array_merge(array('total_rows' => $total, 'num_links' => 3, 'per_page' => $limit, 'uri_segment' => 0, 'base_url' => '', 'page_query_string' => false, 'first_link' => '第一頁', 'last_link' => '最後頁', 'prev_link' => '上一頁', 'next_link' => '下一頁', 'full_tag_open' => '<ul class="pagination">', 'full_tag_close' => '</ul>', 'first_tag_open' => '<li class="f">', 'first_tag_close' => '</li>', 'prev_tag_open' => '<li class="p">', 'prev_tag_close' => '</li>', 'num_tag_open' => '<li>', 'num_tag_close' => '</li>', 'cur_tag_open' => '<li class="active"><a href="#">', 'cur_tag_close' => '</a></li>', 'next_tag_open' => '<li class="n">', 'next_tag_close' => '</li>', 'last_tag_open' => '<li class="l">', 'last_tag_close' => '</li>'), $configs))->create_links();
$articles = Article::find('all', array('offset' => $offset, 'limit' => $limit, 'order' => 'id DESC', 'conditions' => $conditions));
if ($articles) {
$this->add_meta(array('name' => 'keywords', 'content' => implode(',', column_array($articles, 'title')) . ',' . implode(',', Cfg::setting('site', 'site', 'keywords'))))->add_meta(array('name' => 'description', 'content' => $articles[0]->mini_content(150)))->add_meta(array('property' => 'og:title', 'content' => '知識文章' . ' - ' . Cfg::setting('site', 'site', 'title')))->add_meta(array('property' => 'og:description', 'content' => $articles[0]->mini_content(300)))->add_meta(array('property' => 'og:image', 'tag' => 'larger', 'content' => $img = $articles[0]->cover->url('1200x630c'), 'alt' => '知識文章' . ' - ' . Cfg::setting('site', 'site', 'title')))->add_meta(array('property' => 'og:image:type', 'tag' => 'larger', 'content' => 'image/' . pathinfo($img, PATHINFO_EXTENSION)))->add_meta(array('property' => 'og:image:width', 'tag' => 'larger', 'content' => '1200'))->add_meta(array('property' => 'og:image:height', 'tag' => 'larger', 'content' => '630'))->add_meta(array('property' => 'article:modified_time', 'content' => $articles[0]->updated_at->format('c')))->add_meta(array('property' => 'article:published_time', 'content' => $articles[0]->created_at->format('c')));
if (($tags = column_array($articles[0]->tags, 'name')) || ($tags = Cfg::setting('site', 'site', 'keywords'))) {
foreach ($tags as $i => $tag) {
if (!$i) {
$this->add_meta(array('property' => 'article:section', 'content' => $tag))->add_meta(array('property' => 'article:tag', 'content' => $tag));
} else {
$this->add_meta(array('property' => 'article:tag', 'content' => $tag));
}
}
}
}
return $this->set_title('知識文章' . ' - ' . Cfg::setting('site', 'site', 'title'))->load_view(array('articles' => $articles, 'pagination' => $pagination, 'columns' => $columns));
}
示例3: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$counts = array();
$counts['article_total'] = \Article::count();
$counts['category_total'] = \Category::count();
$counts['user_total'] = \User::count();
$counts['page_total'] = \Page::count();
return View::make('admin.index.index')->with('counts', $counts);
}
示例4: actionLabels
public function actionLabels()
{
$criteria = new CDbCriteria();
//AR的另一种写法
$criteria->condition = "userid=" . Yii::app()->session['uid'];
$labelModel = new Article();
$total = $labelModel->count($criteria);
//统计条数
$pager = new CPagination($total);
$pager->pageSize = 7;
$pager->applyLimit($criteria);
$labels = $labelModel->findAll($criteria);
$data = array('pages' => $pager, 'labels' => $labels);
$this->render('labels', $data);
}
示例5: index
public function index($offset = 0)
{
$columns = array(array('key' => 'user_id', 'title' => '作者', 'sql' => 'user_id = ?', 'select' => array_map(function ($user) {
return array('value' => $user->id, 'text' => $user->name);
}, User::all(array('select' => 'id, name')))), array('key' => 'is_visibled', 'title' => '是否公開', 'sql' => 'is_visibled = ?', 'select' => array_map(function ($key) {
return array('value' => $key, 'text' => Article::$visibleNames[$key]);
}, array_keys(Article::$visibleNames))), array('key' => 'title', 'title' => '標題', 'sql' => 'title LIKE ?'), array('key' => 'content', 'title' => '內容', 'sql' => 'content LIKE ?'));
$configs = array('admin', $this->get_class(), '%s');
$conditions = conditions($columns, $configs);
Article::addConditions($conditions, 'destroy_user_id IS NULL');
$limit = 25;
$total = Article::count(array('conditions' => $conditions));
$offset = $offset < $total ? $offset : 0;
$this->load->library('pagination');
$pagination = $this->pagination->initialize(array_merge(array('total_rows' => $total, 'num_links' => 5, 'per_page' => $limit, 'uri_segment' => 0, 'base_url' => '', 'page_query_string' => false, 'first_link' => '第一頁', 'last_link' => '最後頁', 'prev_link' => '上一頁', 'next_link' => '下一頁', 'full_tag_open' => '<ul class="pagination">', 'full_tag_close' => '</ul>', 'first_tag_open' => '<li>', 'first_tag_close' => '</li>', 'prev_tag_open' => '<li>', 'prev_tag_close' => '</li>', 'num_tag_open' => '<li>', 'num_tag_close' => '</li>', 'cur_tag_open' => '<li class="active"><a href="#">', 'cur_tag_close' => '</a></li>', 'next_tag_open' => '<li>', 'next_tag_close' => '</li>', 'last_tag_open' => '<li>', 'last_tag_close' => '</li>'), $configs))->create_links();
$articles = Article::find('all', array('offset' => $offset, 'limit' => $limit, 'order' => 'id DESC', 'include' => array('user'), 'conditions' => $conditions));
Session::setData('admin_articles_index_url', current_url());
return $this->set_tab_index(1)->set_subtitle('文章列表')->add_hidden(array('id' => 'is_visibled_url', 'value' => base_url('admin', $this->get_class(), 'is_visibled')))->load_view(array('articles' => $articles, 'pagination' => $pagination, 'columns' => $columns));
}
示例6: newscatalogue
function isolate_list_by_cat($catalogue_id = 0, $offset = 0, $limit = 20)
{
$newscatalogue = new newscatalogue($catalogue_id);
$news = new article();
$news->where('newscatalogue_id', $catalogue_id);
$news->where(array('recycle' => 0));
$news->order_by('id', 'desc');
$news->get_paged($offset, $limit, TRUE);
$total = count($news);
setPagination($this->admin . 'cnews/isolate_list_by_cat/' . $catalogue_id, $news->paged->total_rows, $limit, 5);
if (!$newscatalogue->exists()) {
show_404();
}
$dis['base_url'] = base_url();
$dis['view'] = 'news/isolate_list';
$dis['news'] = $news;
$dis['title_table'] = "Trang hiện tại:" . $news->paged->current_page . '/' . $news->paged->total_pages;
$dis['title'] = "Tin danh mục \"{$newscatalogue->name_vietnamese}\"";
$n = new Article();
$n->where('newscatalogue_id', $catalogue_id);
$n->where(array('recycle' => 1));
$count_recycle = $n->count();
$dis['nav_menu'] = array(array("type" => "add", "text" => "Thêm tin mới", "link" => "{$this->admin_url}cnews/isolate_edit/" . $catalogue_id, "onclick" => ""));
if ($this->logged_in_user->adminrole->id == 1) {
array_push($dis['nav_menu'], array("type" => "recycle", "text" => "Thùng rác <span style='color:red'>(" . $count_recycle . ") </span>", "link" => "{$this->admin_url}cnews/list_recycle_by_cat/" . $catalogue_id, "onclick" => ""));
}
$this->session->set_userdata(array(config_item('session_admin') . 'menu_current' => $newscatalogue->navigation));
if (empty($newscatalogue->menu_active)) {
$dis['menu_active'] = $newscatalogue->name_vietnamese;
} else {
$dis['menu_active'] = $newscatalogue->menu_active;
}
$this->viewadmin($dis);
}
示例7: arrange_position_home
private function arrange_position_home()
{
$o = new Article();
$o->where('home_hot', 1);
$o->order_by('home_hot_position', 'asc');
$o->get();
$c = $o->count();
$i = 1;
foreach ($o as $row) {
$i++;
$row->home_hot_position = $i;
$row->save();
}
}
示例8: index
public function index($parameter = null)
{
$this->model('Article');
/*
* If no parameter is received then will be the index page.
*/
if (!$parameter) {
$article = new Article();
$data['bits'] = objectToArray($article->articleList('Bits', 'SECURL', 0, 10));
$data['article'] = objectToArray($article->articleList(1, 'FEATURED', 0, 10));
if (sizeof($data['article']) < 8) {
$data['article'] = array_merge(objectToArray(objectToArray($article->articleList(0, 'TYPE', 0, 10))));
}
$data['username'] = "Anush";
$data['TITLE'] = "Tech Stream";
$data['DESCRIPTION'] = "Tech stream is a Web Design and Development blog dedicated to provide inspiring and innovative contents.";
$this->view('home/index.html', $data);
} else {
/*
* In case of parameter the following checking has to be done :
* 1. If parameter is an article
* 2. If parameter is a Page
* 1. If the parameter is name of section.
*/
$article = new Article($parameter);
/*
* If the Parameter represents Public URL of an entry then its a valid request
*/
if ($article->count()) {
$data = objectToArray($article->data());
$data['CONTENT'] = str_replace('[IMAGE]', MEDIAPATH, $data['CONTENT']);
$data['DESCRIPTION'] = $data['DES'];
$data['CANONICAL'] = PUBLICPATH . $data['LINK'];
$data['TITLE '] = $data['TITLE'] . "| Tech Stream";
$data['sidebar']['article'] = objectToArray($article->articleList(0, 'TYPE', 0, 5));
switch ($article->data()->TEMPLATE) {
case 0:
$this->view('home/article.html', $data);
break;
case 1:
$this->view('home/bits.html', $data);
break;
default:
$this->view('home/bits.html', $data);
break;
}
} else {
$parameter = explode('/', $parameter);
if ($parameter[0] == 'All') {
$targetParameter = 0;
$targetEntry = 'TEMPLATE';
} else {
$targetParameter = $parameter[0];
$targetEntry = 'SECURL';
}
$section = $article->articleList($targetParameter, $targetEntry);
$total = $article->count();
if ($section) {
$data['start'] = 0;
$data['page'] = 1;
$data['limit'] = 10;
// Number of articles on a page
$data['sectionUrl'] = PUBLICPATH . $parameter[0];
$total = $article->count();
$data['totalArticle'] = $total;
if (!isset($parameter[1]) || $parameter[1] < 1) {
$parameter[1] = 1;
}
if (is_numeric($parameter[1])) {
$data['page'] = $parameter[1];
$data['start'] = $data['limit'] * ($parameter[1] - 1);
if ($data['start'] >= $total) {
// Redirect to 404
echo "no found";
die;
}
}
$data['sidebar']['article'] = objectToArray($article->articleList(0, 'TYPE', 0, 5));
$data['items'] = objectToArray($article->articleList($targetParameter, $targetEntry, $data['start'], $data['limit']));
if ($targetParameter) {
$data['TITLE'] = removeHyphen($data['items'][0]['SECURL']) . "| Tech Stream";
} else {
$data['TITLE'] = "All Articles" . "| Tech Stream";
}
$data['TOTAL'] = $total;
$data['DESCRIPTION'] = "Find out the list of articles and posts in : " . $data['TITLE'];
if ($data['items'][0]['TYPE'] == 1) {
$this->view('home/list.bits.html', $data);
} else {
$this->view('home/list.article.html', $data);
}
} else {
$article = new Article('NotFound');
$data = objectToArray($article->data());
$data['CONTENT'] = str_replace('[IMAGE]', MEDIAPATH, $data['CONTENT']);
$data['sidebar']['article'] = objectToArray($article->articleList(0, 'TYPE', 0, 5));
$data['DESCRIPTION'] = $data['DES'];
$this->view('home/bits.html', $data);
}
}
//.........这里部分代码省略.........
示例9: testEloquentORM
public function testEloquentORM()
{
// Insert
$article = new Article();
$article->title = static::ARTICLE_TITLE;
$saved = $article->save();
$this->assertTrue($saved);
$this->assertEquals(1, $article->id);
$id = $article->id;
// Select
$article = Article::find($id);
$this->assertInstanceOf('Article', $article);
$this->assertEquals(static::ARTICLE_TITLE, $article->title);
// Delete
$deleted = Article::destroy($id);
$this->assertEquals(1, $deleted);
// Count
$count = Article::count();
$this->assertEquals(0, $count);
}
示例10: post
public function post($post_id)
{
$this->model('User');
$this->model('Article');
$user = new User();
$article = new Article();
$this->loginRequired($user);
// If new post is to be created
if (empty($post_id) || $post_id == 'new') {
if (Input::exists()) {
$validate = new Validate();
// Validation for Inputs
$validation = $validate->check($_POST, array('title' => array('name' => 'Post title', 'required' => true, 'min' => 5), 'description' => array('name' => 'description', 'required' => true, 'min' => 50), 'featuredimage' => array('name' => 'Featured Image', 'required' => true), 'link' => array('name' => 'Article Link', 'required' => true, 'unique' => ARTICLE_TABLE)));
if (empty(Input::get('type'))) {
$type = 0;
} else {
$type = 1;
}
if ($validate->passed()) {
$template = Strings::get('catagory');
try {
$article->create(array('TITLE' => Input::get('title'), 'SECURL' => Input::get('catagory'), 'SUBSEC' => Input::get('subsec'), 'CREATED_DATE' => date("Y-m-d H:i:s", time()), 'IMG' => Input::get('featuredimage'), 'DES' => Input::get('description'), 'LINK' => Input::get('link'), 'TYPE' => $type, 'TEMPLATE' => Input::get('template')));
// Get the created article details from LINK to redirect the user to edit it.
$newarticle = new Article(Input::get('link'));
Redirect::to(ADMINPATH . 'post/' . $newarticle->data()->SL_NO);
} catch (Exception $e) {
die($e->getMessage());
}
if (isset($data)) {
$submissionData = Input::values($_POST);
$data = array_merge($data, $submissionData);
} else {
$data = Input::values($_POST);
}
} else {
$data = $validate->errors();
}
}
if (isset($data)) {
$submissionData = Input::values($_POST);
$data = array_merge($data, $submissionData);
} else {
$data = Input::values($_POST);
}
$data['CATAGORY'] = Strings::get('catagory');
$data['SUBCATAGORY'] = Strings::get('subcatagory');
$data['TEMPLATES'] = Strings::get('templates');
$data['token'] = Token::generate();
$data['TITLE'] = "Create New Post";
$this->view('admin/post.new.html', $data);
} else {
/**
* Edit Post section
*
* The edit and after creation events happen here
*/
$article = new Article($post_id);
if (Input::exists()) {
$validate = new Validate();
// Validation for Inputs
$validation = $validate->check($_POST, array('title' => array('name' => 'Post title', 'required' => true, 'min' => 5), 'description' => array('name' => 'description', 'required' => true, 'min' => 50), 'featuredimage' => array('name' => 'Featured Image', 'required' => true)));
// If Article URL is changed check if it already exist
if ($validate->passed() && $article->data()->LINK != Input::get('link')) {
$validation = $validate->check($_POST, array('link' => array('name' => 'Article Link', 'required' => true, 'unique' => ARTICLE_TABLE)));
}
if (empty(Input::get('type'))) {
$type = 0;
} else {
$type = 1;
}
if (empty(Input::get('featured'))) {
$featured = 0;
} else {
$featured = 1;
}
if (Input::get('publish') == 1) {
$publish = $article->data()->STATUS ? 0 : 1;
} else {
$publish = $article->data()->STATUS;
}
if ($validation) {
$template = Strings::get('catagory');
try {
$article->update(array('TITLE' => Input::get('title'), 'SECURL' => Input::get('catagory'), 'SUBSEC' => Input::get('subsec'), 'CONTENT' => Input::get('content'), 'DATE' => Input::get('date'), 'IMG' => Input::get('featuredimage'), 'DES' => Input::get('description'), 'LINK' => Input::get('link'), 'TYPE' => $type, 'TEMPLATE' => Input::get('template'), 'FEATURED' => $featured, 'STATUS' => $publish), $post_id);
Redirect::to(ADMINPATH . 'post/' . $post_id);
} catch (Exception $e) {
die($e->getMessage());
}
if (isset($data)) {
$submissionData = Input::values($_POST);
$data = array_merge($data, $submissionData);
} else {
$data = Input::values($_POST);
}
} else {
$data = $validate->errors();
}
}
if ($article->count()) {
if (isset($data)) {
//.........这里部分代码省略.........
示例11: testToXmlProxiesOptionsToCollection
public function testToXmlProxiesOptionsToCollection()
{
$this->fixtures('articles');
$testCount = Article::count();
$tests = Article::find('all', array('offset' => '2', 'limit' => '2'));
$models = new Mad_Model_PaginatedCollection($tests, 2, 2, $testCount);
$this->assertContains('<articles>', $models->toXml(array('skipTypes' => true)));
}
示例12: no_testCountMethodFiltersPassedOptions
public function no_testCountMethodFiltersPassedOptions()
{
$opts = ['conditions' => [], 'having' => [], 'groupBy' => []];
$qb = $this->getMock('\\SimpleAR\\Orm\\Builder', array('setOptions', 'count'));
$qb->expects($this->once())->method('setOptions')->with($opts)->will($this->returnValue($qb));
$qb->expects($this->once())->method('count');
Article::setQueryBuilder($qb);
$opts['select'] = ['title', 'stuff'];
$opts['orderBy'] = ['#readers'];
Article::count($opts);
}