本文整理汇总了PHP中Entity::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Entity::model方法的具体用法?PHP Entity::model怎么用?PHP Entity::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Entity
的用法示例。
在下文中一共展示了Entity::model方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getEntity
/**
* 返回对应的Entity
*/
public function getEntity()
{
if (!$this->_entity) {
$this->_entity = Entity::model()->findByAttributes(array('id' => $this->entityId));
}
return $this->_entity;
}
示例2: getIdByType
public static function getIdByType($type)
{
$entity = Entity::model()->find('type=:type', array(':type' => $type));
if ($entity) {
return $entity->id;
} else {
return false;
}
}
示例3: array
<?php
/* @var $this NoticeController */
/* @var $data Notice */
$comment = Comment::model()->findByPk($data['commentId']);
$entity = Entity::model()->findByPk($comment->commentableEntityId);
if (!$comment || !$entity->getModel()) {
return false;
}
?>
<?php
echo CHtml::link($comment->user->name, $comment->user->pageUrl);
?>
回复了
<?php
echo $entity->getTypeLabel();
?>
<?php
echo CHtml::link($entity->getTypeLabel(), array($entity->type . '/view', 'id' => $entity->getModel()->id));
示例4: array
<?php
/* @var $this NoticeController */
/* @var $data Notice */
$vote = Vote::model()->findByPk($data['voteid']);
$entity = @Entity::model()->findByPk($vote->voteableEntityId);
$model = @$entity->getModel();
if (!$vote || !$model) {
return false;
}
?>
你的
<?php
echo $entity->getTypeLabel();
echo CHtml::link($entity->getTitle(), array($entity->type . '/view', 'id' => $model->id));
?>
新增加一个<em><?php
echo $vote->value > 0 ? "<span style=\"color:green\">赞同</span>" : "<span style=\"color:red\">反对</span>";
?>
</em>
示例5: actionAddComment
public function actionAddComment($commentableEntityId)
{
$comment = new Comment();
//$model = $this->loadModel($id?$id:$lessonId);
$entity = Entity::model()->findByPk($commentableEntityId);
$model = $entity->getModel();
if (isset($_POST['Comment'])) {
$comment->attributes = $_POST['Comment'];
if ($model->addComment($comment)) {
Yii::app()->user->setFlash('success', Yii::t('app', '发表成功!'));
} else {
Yii::app()->user->setFlash('error', Yii::t('app', '抱歉,发表失败!'));
}
if ($model instanceof Lesson) {
$course = $model->course;
} else {
$course = $model;
}
//if($model->addComment($comment)){
$commentDataProvider = $course->getCommentDataProvider();
// var_dump($commentDataProvider->getData());
$this->renderPartial('_comments', array('commentDataProvider' => $commentDataProvider, 'course' => $course), false, true);
// }
}
}