本文整理汇总了PHP中Article::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Article::model方法的具体用法?PHP Article::model怎么用?PHP Article::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Article
的用法示例。
在下文中一共展示了Article::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadNewArticle
private function loadNewArticle($num = 3)
{
$uid = Ibos::app()->user->uid;
$allDeptId = Ibos::app()->user->alldeptid . "";
$allPosId = Ibos::app()->user->allposid . "";
$deptCondition = "";
$deptIdArr = explode(",", $allDeptId);
if (0 < count($deptIdArr)) {
foreach ($deptIdArr as $deptId) {
$deptCondition .= "FIND_IN_SET('{$deptId}',deptid) OR ";
}
$deptCondition = substr($deptCondition, 0, -4);
} else {
$deptCondition = "FIND_IN_SET('',deptid)";
}
$condition = " ( ((deptid='alldept' OR {$deptCondition} OR FIND_IN_SET('{$allPosId}',positionid) OR FIND_IN_SET('{$uid}',uid)) OR (deptid='' AND positionid='' AND uid='') OR (author='{$uid}') OR (approver='{$uid}')) ) AND `status`='1'";
$criteria = array("select" => "articleid,subject,content,addtime,type", "condition" => $condition, "order" => "`istop` DESC, `addtime` DESC", "offset" => 0, "limit" => $num);
$articles = Article::model()->fetchAll($criteria);
if (!empty($articles)) {
foreach ($articles as &$article) {
$read = ArticleReader::model()->fetchByAttributes(array("articleid" => $article["articleid"], "uid" => $uid));
$readStatus = $read ? 1 : 0;
if ($readStatus) {
$article["iconStyle"] = $this->iconReadStyle[$article["type"]];
} else {
$article["iconStyle"] = $this->iconNormalStyle[$article["type"]];
}
}
}
return $articles;
}
示例2: getNews
public function getNews($id)
{
$gUid = Ibos::app()->user->uid;
$article = Article::model()->fetchByPk($id);
$attribute = ICArticle::getShowData($article);
return $attribute;
}
示例3: actionView
public function actionView()
{
$article_id = $_GET['article_id'];
$article = Article::model()->findByPk($article_id);
$this->data['article'] = $article;
$this->render('view', $this->data);
}
示例4: loadModel
public function loadModel($id)
{
if (($model = Article::model()->findByPk($id)) === null) {
throw new CHttpException(404, 'Страница не найдена');
}
return $model;
}
示例5: actionIndex
/**
* This is the default 'index' action that is invoked
* when an action is not explicitly requested by users.
*/
public function actionIndex()
{
$criteria = new CDbCriteria();
$criteria->limit = 6;
$news = Article::model()->published()->findAll($criteria);
$this->render('index', array('news' => $news));
}
示例6: delete
public function delete($catid)
{
$clear = false;
$ids = $this->fetchAllSubId($catid);
$idStr = implode(",", array_unique(explode(",", trim($ids, ","))));
if (empty($idStr)) {
$idStr = $catid;
} else {
$idStr .= "," . $catid;
}
$count = Article::model()->count("catid IN ({$idStr})");
if ($count) {
return -1;
}
if (!is_null($this->_related)) {
$count = $this->_related->count("`{$this->index}` IN ({$idStr})");
!$count && ($clear = true);
} else {
$clear = true;
}
if ($clear) {
$status = $this->_category->deleteAll("FIND_IN_SET({$this->index},'{$idStr}')");
$this->afterDelete();
return $status;
} else {
return false;
}
}
示例7: actionFeel
public function actionFeel()
{
$keywords = Yii::app()->request->getParam('keywords');
$sql = "select * from {{article}} where title like'%{$keywords}%' order by create_time desc";
$article = Article::model()->findAllBySql($sql);
$data = array('article' => $article, 'id' => $keywords);
$this->render('feel', $data);
}
示例8: loadModelByAlias
public function loadModelByAlias($alias)
{
$model = Article::model()->find('alias=:alias', array(':alias' => $alias));
if ($model === null) {
throw new CHttpException(404, 'Запрашиваемая страница не существует.');
}
return $model;
}
示例9: loadModel
/**
* Returns the data model based on the primary key given in the GET variable.
* If the data model is not found, an HTTP exception will be raised.
* @param integer $id the ID of the model to be loaded
* @return Article the loaded model
* @throws CHttpException
*/
public function loadModel($url)
{
$model = Article::model()->findByAttributes(array('url' => $url));
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $model;
}
示例10: actionShow
public function actionShow($alias)
{
$model = Article::model()->published()->findByAlias($alias);
if (!$model) {
throw new CHttpException(404, Yii::t('PublicationModule.publication', 'Article was not found!'));
}
$this->render('show', array('model' => $model));
}
示例11: actionNews
public function actionNews()
{
$newsData = Article::model()->getBriefArticlesData(null, Article::POST_TYPE_NEWS);
$newsData->pagination = new CPagination(self::listingsPerPage);
$this->breadcrumbs = array('News');
$this->tabMenus = array(array('label' => 'Articles', 'url' => array('/site/articles')), array('label' => 'News', 'active' => true), array('label' => 'Events', 'url' => array('/event/event/index')), array('label' => 'Workshops', 'url' => array('//site/workshops')));
$this->render('news', array('newsData' => $newsData));
}
示例12: actionIndex
public function actionIndex($cid)
{
$article = Yii::app()->cache->get('cache');
if ($article == false) {
$article = Article::model()->findAllBySql('SELECT * FROM {{article}} WHERE cid = ' . $cid);
Yii::app()->cache->set('cache', $article);
}
$this->render('index', array('article' => $article));
}
示例13: actionView
public function actionView($id)
{
//$this->layout='//layouts/inner';
$criteria = new CDbCriteria();
$criteria->order = 'sorter';
$criteria->condition = 'active=1';
$articles = Article::model()->findAll($criteria);
$this->render('view', array('model' => $this->loadModel($id), 'articles' => $articles));
}
示例14: run
public function run()
{
$criteria = new CDbCriteria();
if ($this->limit > 0) {
$criteria->limit = (int) $this->limit;
}
$models = Article::model()->sortByDate('DESC')->published()->findAll($criteria);
$this->render($this->view, array('models' => $models));
}
示例15: actionIndex
public function actionIndex()
{
$db = Account::model()->getDbConnection();
$total = $db->createCommand("SELECT SUM(amount) FROM account")->queryScalar();
$criteria = new CDbCriteria();
$criteria->order = "id DESC";
$criteria->limit = 5;
$articles = Article::model()->findAll($criteria);
$this->render('index', array('total' => $total, 'articles' => $articles));
}