model() public static method

Returns the static model of the specified AR class.
public static model ( $className = __CLASS__ ) : FriendLink
return FriendLink the static model class
示例#1
0
 /**
  * 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 = FriendLink::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
示例#2
0
 public function getLink()
 {
     $cri = new CDbCriteria(array('order' => 'sort_order asc', 'limit' => '7'));
     $friendlink = FriendLink::model()->findAll($cri);
     return $friendlink;
 }
示例#3
0
<?php

$category = Category::model()->findByPk(107);
$childs = $category->children()->findAll();
foreach ($childs as $child) {
    ?>
<div class="row">
<div class="col-span-12 friend-link">
    <ul>
	<li><?php 
    echo $child->name;
    ?>
</li>
	<?php 
    $cri = new CDbCriteria(array('condition' => 'category_id = ' . $child->id, 'order' => 'link_id asc, sort_order asc'));
    $links = FriendLink::model()->findAll($cri);
    foreach ($links as $l) {
        ?>
	<li><?php 
        echo CHtml::link($l->title, $l->url, array('target' => '_blank'));
        ?>
</li>
	<?php 
    }
    ?>
    </ul>
</div>
</div>
<?php 
}
示例#4
0
	public function actionlinkdel($id)
	{
		$model = FriendLink::model()->findByPk($id);
		if($model->delete()){
			Yii::app()->user->setFlash('success','删除成功!');
		}else{
			Yii::app()->user->setFlash('error','删除失败,请重试!');
		}
		$this->redirect('/srbac/config/flink');
	}