本文整理汇总了PHP中Entry::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Entry::model方法的具体用法?PHP Entry::model怎么用?PHP Entry::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Entry
的用法示例。
在下文中一共展示了Entry::model方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getActiveEntry
/**
* Returns the active entry or null if there is no active entry.
* @return Entry || null
*/
public function getActiveEntry()
{
if ($this->_activeEntryId === null) {
return null;
}
return Entry::model()->findByPk($this->_activeEntryId, 'deleted=0');
}
示例2: run
/**
* (non-PHPdoc)
* @see yii/CWidget#run()
*/
public function run()
{
// criteria for last entries
$c = new CDbCriteria();
$c->order = 't.viewCount DESC';
$c->limit = Setting::model()->name(Setting::MOST_VIEWED_ENTRIES_WIDGET_COUNT)->find()->value;
// get entries
$models = Entry::model()->findAll($c);
// render view
$this->render('mostViewed', array('models' => $models));
}
示例3: actionCsv
/**
*
* @return void
*/
public function actionCsv()
{
Yii::import('ext.ECSVExport');
$data = array();
foreach (Entry::model()->findAllByAttributes(array('userId' => Yii::app()->user->id)) as $model) {
/* @var Entry $model */
$data[] = array('name' => $model->name, 'url' => $model->url, 'comment' => $model->comment, 'tags' => $model->tagList, 'username' => $model->username, 'password' => $model->password);
}
$csv = new ECSVExport($data);
Yii::app()->request->sendFile(sprintf('ppma-export-%s', date('YmdHis')), $csv->toCSV(), 'text/csv', false);
}
示例4: run
public function run()
{
// criteria for last entries
$c = new CDbCriteria();
$c->order = 't.id DESC';
/** @noinspection PhpUndefinedMethodInspection */
$c->limit = Setting::model()->name(Setting::RECENT_ENTRIES_WIDGET_COUNT)->find()->value;
// get entries
$models = Entry::model()->findAll($c);
// render view
$this->render('recent', array('models' => $models));
}
示例5: actionSearchName
/**
* @param string $term
*/
public function actionSearchName($term)
{
// escape $term
$term = CPropertyValue::ensureString($term);
// create criteria
$c = new CDbCriteria();
$c->distinct = true;
$c->addSearchCondition('name', $term);
$c->limit = 5;
// save results
$result = array();
foreach (Entry::model()->findAll($c) as $model) {
/* @var Entry $model */
$result[] = $model->name;
}
// output result as JSON
echo CJSON::encode($result);
}
示例6: renderProfileDetail
private function renderProfileDetail($model)
{
// $roles = Yii::app()->authManager->getRoles($model->getPrimaryKey());
$role = $model->role;
if (!empty($role)) {
if ($role == 'admin' || $role == 'teacher') {
$criteria = new CDbCriteria();
$criteria->order = 'created_date DESC';
$criteria->condition = 'owner_by = :owner_by';
$criteria->params = array(':owner_by' => $model->getPrimaryKey());
$count = Entry::model()->count($criteria);
$pages = new CPagination($count);
// results per page
$pages->pageSize = Yii::app()->params['entriesPerPage'];
$pages->applyLimit($criteria);
$entries = Entry::model()->findAll($criteria);
$dataRender = array('model' => $model, 'entries' => $entries, 'pages' => $pages);
if ($this->getRoute() == 'account/update') {
$dataRender['mode'] = 'edit';
}
$this->render('view_teacher', $dataRender);
} elseif ($role == 'student') {
$dataRender = array('model' => $model);
if ($this->getRoute() == 'account/update') {
$dataRender['mode'] = 'edit';
}
$this->render('view_student', $dataRender);
} else {
$dataRender = array('model' => $model);
if ($this->getRoute() == 'account/update') {
$dataRender['mode'] = 'edit';
}
$this->render('view_user', $dataRender);
}
}
}
示例7: actionUpdate
/**
* Updates a particular model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id the ID of the model to be updated
*/
public function actionUpdate($id)
{
$model = $this->loadModel($id);
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
$count = isset($_POST['entryCount']) ? intval($_POST['entryCount']) : 0;
if (isset($_POST['Invoice'])) {
$model->attributes = $_POST['Invoice'];
for ($i = 0; $i < $count; $i++) {
//$item = new Item;
//$item->attributes = $_POST["Item$i"];
//$pk = $item->id;
$_item = Entry::model()->findByPk(intval($_POST["Entry{$i}" . "_id"]));
$_item->attributes = $_POST["Entry{$i}"];
$_item->save();
}
if ($model->save()) {
$this->redirect(array('view', 'id' => $model->id));
}
}
$this->render('update', array('model' => $model, 'entries' => $model->Entries));
}
示例8: 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 the ID of the model to be loaded
*/
public function loadModel($id)
{
$model = Entry::model()->findByPk($id);
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $model;
}
示例9: loadModel
/**
* @param int $id
* @return Entry
* @throws CHttpException
*/
protected function loadModel($id)
{
$model = Entry::model()->findbyPk($id);
if ($model === null) {
throw new CHttpException(404);
} elseif ($model->userId != Yii::app()->user->id) {
throw new CHttpException(403);
}
return $model;
}