Skip to content

Instantly share code, notes, and snippets.

View jamband's full-sized avatar
👀
web browser

Tomoki Morita jamband

👀
web browser
View GitHub Profile
@jamband
jamband / Hoge.php
Last active September 28, 2015 10:38
<?php
class Hoge extends CActiveRecord
{
public $username; // 追加
...
/**
* @see CModel::rules()
*/
public function rules()
@jamband
jamband / admin.php
Last active September 28, 2015 10:38
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id' => 'hoge-grid',
'dataProvider' => $model->search(),
'filter' => $model,
'columns' => array(
'id',
array(
'name' => 'username',
'value' => '$data->user->username',
),
<?php
class HogeController extends Controller
{
public function actions()
{
return array(
'edit' => array(
'class' => 'application.components.actions.EditAction'
),
'delete' => array(
<?php
class HogeController extends Controller
{
public function actions()
{
return array(
'edit' => array(
'class' => 'actions.EditAction',
//'class' => 'EditAction', // import に追加している場合
),
@jamband
jamband / Hoge.php
Last active September 28, 2015 10:38
<?php
class Hoge extends CActiveRecord
{
...
/**
* @see CActiveRecord::scopes()
*/
public function scopes()
{
return array(
<?php
class HogeController extends Controller
{
/**
* Lists all models.
*/
public function actionIndex()
{
list($pages, $models) = Hoge::model()->getAll();
$this->render('index', compact('pages', 'models'));
@jamband
jamband / index.php
Last active September 28, 2015 10:38
<?php $this->widget('CLinkPager', compact('pages')); ?>
<?php echo CHtml::encode('結果数: ' . $pages->itemCount . ' 件'); ?>
<?php foreach ($models as $model): ?>
<div class="view">
<?php echo CHtml::encode($model->fuga); ?>
<?php echo CHtml::encode($model->piyo); ?>
<br />
</div><!-- /.view -->
<?php endforeach; ?>
@jamband
jamband / main.php
Last active September 28, 2015 10:38
<?php
...
'components' => array(
'db' => array(
'enableProfiling' => true, // 追加
...
),
'log' => array(
'class' => 'CLogRouter',
'routes' => array(
<?php
class UpdateAction extends CAction
{
/**
* リダイレクト先
*/
public $redirect = 'view';
public function run($id)
{
<?php
class HogeController extends Controller
{
...
public function actions()
{
return array(
// アクション名を指定 ( actionUpdateとなる )
'update' => array(
'class' => 'application.components.actions.UpdateAction', // パス名指定