我正在使用几个月前安装的yii2版本.现在我希望它升级到最新版本.我如何知道正在使用哪个版本的Yii2以及如何升级到最新版本的yii2?
如何RBAC在Yii 2.0没有任何数据库的情况下实现.我将只有两个角色,即admin and author.我的RbacController是
<?php
namespace app\commands;
use Yii;
use yii\console\Controller;
class RbacController extends Controller
{
public function actionInit()
{
$auth = \Yii::$app->authManager;
// add "createPost" permission
$createPost = $auth->createPermission('createPost');
$createPost->description = 'Create a post';
$auth->add($createPost);
// add "updatePost" permission
$updatePost = $auth->createPermission('updatePost');
$updatePost->description = 'Update post';
$auth->add($updatePost);
// add "author" role and give this role the "createPost" permission
$author = $auth->createRole('author');
$auth->add($author);
$auth->addChild($author, $createPost);
// add "admin" role and give this role the …Run Code Online (Sandbox Code Playgroud) 在Yii2中使用迁移功能,我试图添加一个'authorization_key'在表上调用的新列'users'.我的up功能如下:我的初始run功能就是这个
public function up()
{
$this->createTable( 'users', [
'id' => 'pk',
'username' => 'string UNIQUE',
'password' => 'string'
]);
}
Run Code Online (Sandbox Code Playgroud)
当我./yii migrate up
追赶时./yii migrate/create,桌子就被创建了.
但是在添加之后$this->addColumn('user', 'authorization_key'for', 'string UNIQUE');,即新up功能是
public function up()
{
$this->createTable( 'users', [
'id' => 'pk',
'username' => 'string UNIQUE',
'password' => 'string'
]);
$this->addColumn('user', 'authorization_key'for', 'string UNIQUE');
}
Run Code Online (Sandbox Code Playgroud)
然后我跑
./yii migrate up
Run Code Online (Sandbox Code Playgroud)
,它没有工作,并没有创建新专栏,但它显示
No new migration found. Your system is up-to-date. …Run Code Online (Sandbox Code Playgroud) 我的模型中的行为功能如下
public function behaviors()
{
return [
'timestamp' => [
'class' => 'yii\behaviors\TimestampBehavior',
'attributes' => [
ActiveRecord::EVENT_BEFORE_INSERT => ['log_in_time' ],
ActiveRecord::EVENT_BEFORE_UPDATE => ['log_in_time'],
],
'value' => new Expression('NOW()'),
],
];
}
/**
* validation rules
*/
public function rules()
{
return [
['username','filter', 'filter' => 'trim'],
['username','required'],
//['username','unique'],
['username','string', 'min' => 2, 'max' => 255],
['password','required'],
];
}
/* Your model attribute labels */
public function attributeLabels()
{
return [
/* Your other attribute labels */
];
}
public function …Run Code Online (Sandbox Code Playgroud) 我正在使用标签导航到不同的视图。这些视图位于中'xype' container。我正在使用这样的功能来加载不同的视图
Ext.getCmp('contactcontainer').setActiveItem(2);
Run Code Online (Sandbox Code Playgroud)
但是我需要在调用新视图时消除滑动效果。怎么做到呢?我正在使用sencha touch 2
怎样才能yii\grid\ActionColumn的GridView::widget仅loggged在用户可见?我的代码是
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'state_id',
'state_name',
'population',
'state_code',
['class' => 'yii\grid\ActionColumn'],
],
]); ?>
Run Code Online (Sandbox Code Playgroud) 我有三张桌子
--
-- Table structure for table `tbl_ticket`
--
CREATE TABLE IF NOT EXISTS `tbl_ticket` (
`id` int(9) NOT NULL,
`complain_id` varchar(250) CHARACTER SET latin1 NOT NULL,
`section_id` varchar(250) CHARACTER SET latin1 NOT NULL,
`location_id` varchar(250) CHARACTER SET latin1 NOT NULL,
`status` varchar(250) CHARACTER SET latin1 NOT NULL,
`remarks` varchar(250) CHARACTER SET latin1 NOT NULL,
`r_date` datetime NOT NULL,
`d_date` datetime NOT NULL,
`hd_user_username` varchar(250) CHARACTER SET latin1 NOT NULL,
`hd_user_email` varchar(250) CHARACTER SET latin1 NOT NULL,
`description` varchar(250) NOT …Run Code Online (Sandbox Code Playgroud) 如何在Kartik Gridview中禁用分页?我正在使用如下代码
echo GridView::widget([
'dataProvider'=>$dataProvider,
'filterModel'=>$searchModel,
'showPageSummary'=>true,
'responsive'=>true,
'hover' => true,
'pjax'=>true,
'containerOptions'=>['style'=>'overflow: auto'], // only set when $responsive = false
'headerRowOptions'=>['class'=>'kartik-sheet-style'],
'filterRowOptions'=>['class'=>'kartik-sheet-style'],
'striped'=>true,
'hover'=>true,
'pager' => [
'options'=>['class'=>'pagination'], // set clas name used in ui list of pagination
'prevPageLabel' => 'Previous', // Set the label for the "previous" page button
'nextPageLabel' => 'Next', // Set the label for the "next" page button
'firstPageLabel'=>'First', // Set the label for the "first" page button
'lastPageLabel'=>'Last', // Set the label for the …Run Code Online (Sandbox Code Playgroud) 如何使用 jquery 或 javascript 删除所有出现的带有特定类的标签而不是其中的内容?例如以下必须转换
<a class="ab">
<ol>
<a class="ab">
<li><a class="ab">
abcde</a>
</li>
<li>
<a class="ab">
12354
</a>
</li>
</a>
</ol>
</a>
Run Code Online (Sandbox Code Playgroud)
进入
<ol>
<li>
abcde
</li>
<li>
12354
</li>
</ol>
Run Code Online (Sandbox Code Playgroud)
我想删除所有标签class= "ab"并保留其中的元素和内容