本文整理汇总了PHP中CActiveDataProvider::getKeys方法的典型用法代码示例。如果您正苦于以下问题:PHP CActiveDataProvider::getKeys方法的具体用法?PHP CActiveDataProvider::getKeys怎么用?PHP CActiveDataProvider::getKeys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CActiveDataProvider
的用法示例。
在下文中一共展示了CActiveDataProvider::getKeys方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderKeys
public function renderKeys()
{
echo CHtml::openTag('div', array('class' => 'keys', 'style' => 'display:none', 'title' => Yii::app()->getRequest()->getUrl()));
foreach ($this->dataProvider->getKeys() as $key) {
echo "<span>" . CHtml::encode($key) . "</span>";
}
echo "</div>\n";
}
示例2: getKeys
/**
* Returns the key values associated with the data items.
* @param boolean $refresh whether the keys should be re-calculated.
* @return array the list of key values corresponding to {@link data}. Each data item in
* {@link data}
* is uniquely identified by the corresponding key value in this array.
*/
public function getKeys($refresh = false)
{
/* x2modstart */
if ($this->calculateChecksum && $refresh) {
throw new CException('refresh cannot be called if calculcateChecksum is set to true');
}
/* x2modend */
return parent::getKeys($refresh);
}
示例3: actionBoard
/**
* Lists all models.
*/
public function actionBoard($slug) {
if (!$slug)
throw new CHttpException(404, 'The requested board does not exist.');
$board=Yii::app()->cache->get($slug);
if ($board===false) {
$board=Board::model()->find('slug=:slug', array(':slug'=> $slug));
if ($board)
Yii::app()->cache->set($slug, $board, 2592000); // 1 month
else
throw new CHttpException(404, 'The requested page does not exist.');
}
$this->pageTitle=Yii::app()->name." - ".$board->name;
$model=new Post;
$model->board=$board->id;
if (isset($_POST['Post'])) {
$model->attributes=$_POST['Post'];
$model->image=CUploadedFile::getInstance($model, 'image');
$name=time() . rand(10, 90);
if ($model->image)
$model->filename=$board->slug . "/" . $name . "." . $model->image->getExtensionName();
if ($model->save()) {
$this->uploadImage($name, $board->slug, $model);
$model->addReplies();
$this->redirect(array('thread', 'slug'=> $board->slug, 'id'=> $model->vid));
}
}
$notmain=isset($_GET['Post_page']);
$dataProvider=Yii::app()->cache->get('board' . $board->slug);
if ($notmain || $dataProvider===false) {
$dataProvider=new CActiveDataProvider('Post', array(
'criteria'=> array(
'condition'=> 'board=:boardId AND parent_id=0',
'params'=> array(':boardId'=> $board->id),
'order'=> 'updated DESC',
),
));
// attach replies, need find more correct way
Post::addLastReplies($dataProvider->getData());
$dataProvider->getKeys(); // wtf? without this before set cache we get error
if(!$notmain)
Yii::app()->cache->set('board' . $board->slug, $dataProvider, 86400); // 1 day
}
$this->render('board', array(
'dataProvider'=> $dataProvider,
'model'=> $model,
'board'=> $board,
));
}