上一页 1 2 3 4 5 6 ··· 36 下一页
摘要: Yii2-助手类(ArrayHelper) 数组助手类 ArrayHelper Yii 数组助手类提供了额外的静态方法,让你更高效的处理数组。 模型转数组 $model = Country::findOne(['code'=>'BR']); VarDumper::dump(ArrayHelper:: 阅读全文
posted @ 2024-03-30 14:52 胡勇健 阅读(11) 评论(0) 推荐(0) 编辑
摘要: Yii2-助手类(Html) 引入命名空间 use yii\helpers\Html; 使用 <?php //【一】表单:Html::beginForm(提交地址,提交方法,属性数组);?> <?=Html::beginForm('','post',['id'=>'form','class'=>'f 阅读全文
posted @ 2024-03-30 14:51 胡勇健 阅读(2) 评论(0) 推荐(0) 编辑
摘要: Yii2-助手(StringHelper) 截断字符串 echo StringHelper::truncate('中文截断字符',4); //'中文截断...' 字符串转数组 StringHelper::explode('this is string',' '); //[ 0 => 'this' 1 阅读全文
posted @ 2024-03-30 14:49 胡勇健 阅读(5) 评论(0) 推荐(0) 编辑
摘要: yii2-分页 使用ActiveDataProvider 和 GridView controller public function actionIndex(){ $dataProvider = new ActiveDataProvider([ 'query' => ArticleClass::fi 阅读全文
posted @ 2024-03-30 14:47 胡勇健 阅读(9) 评论(0) 推荐(0) 编辑
摘要: 分页 使用ActiveDataProvider 和 GridView controller public function actionIndex(){ $dataProvider = new ActiveDataProvider([ 'query' => ArticleClass::find(), 阅读全文
posted @ 2024-03-30 14:45 胡勇健 阅读(2) 评论(0) 推荐(0) 编辑
摘要: yii2 密码和加解密 生成hash $hash = Yii::$app->getSecurity()->generatePasswordHash($password); 验证hash if (Yii::$app->getSecurity()->validatePassword($password, 阅读全文
posted @ 2024-03-30 14:43 胡勇健 阅读(8) 评论(0) 推荐(0) 编辑
摘要: yii2-用户认证 配置 yii\web\User return [ 'components' => [ 'user' => [ 'identityClass' => 'app\models\User', 'enableAutoLogin' => true, 'loginUrl' => ['user 阅读全文
posted @ 2024-03-30 14:43 胡勇健 阅读(1) 评论(0) 推荐(0) 编辑
摘要: Yii2 过滤器 过滤器AccessController AccessControl 基于一组规则提供简单的访问控制 /** * {@inheritdoc} */ public function behaviors() { return [ 'access' => [ 'class' => Acce 阅读全文
posted @ 2024-03-30 14:41 胡勇健 阅读(4) 评论(0) 推荐(0) 编辑
摘要: yii2-队列使用 安装yii2-queue composer require yiisoft/yii2-queue 安装yii2-redis composer require yiisoft/yii2-redis 控制台配置文件 console.php 和 web.php 'redis' => [ 阅读全文
posted @ 2024-03-30 14:40 胡勇健 阅读(24) 评论(0) 推荐(0) 编辑
摘要: Yii2验证器Validator 控制器 public function actionIndex() { $data = ['LoginForm'=>['username'=>'huyongjian','password'=>'1234']]; $model = new LoginForm(); $ 阅读全文
posted @ 2024-03-30 14:39 胡勇健 阅读(2) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 36 下一页