yii2

来源:互联网 发布:搬砖小伟的淘宝店 编辑:程序博客网 时间:2024/05/18 02:27
public function actionSay($message = 'Hello')    {        return $this->render('say', ['message' => $message]);    }

实际是say方法,渲染到say视图里面了。

http://hostname/index.php?r=site/say&message=Hello+World

路由 site/say 将被解析至 SiteController 控制器和其中的 say 操作。

读取 country 表的数据去common\model里面创建Country.php

<?phpnamespace app\models;use yii\db\ActiveRecord;class Country extends ActiveRecord{}

操作

use app\models\Country;// 获取 country 表的所有行并以 name 排序$countries = Country::find()->orderBy('name')->all();

例如index 转成 actionIndex, hello-world 转成 actionHelloWorld。

// 如下代码不会生效,只有session这要多次传值
$session[‘captcha’][‘number’] = 5;

$session[‘captcha’][‘lifetime’] = 3600;

public function filters(){    return array(        'postOnly+edit,create',        array(            'filters.xxx.Filter-edit,create',            'unit'=>'second',        ),    );}

在xxxFilter文件下,当执行edit和create的post请求过滤器时才执行这个操作

session保存在哪,php.ini搜索“session.save_path”
———————我是分割线———————–
**

验证码

**,流程是:先前台验证,然后我后台验证,再生成随机四位数,然后通过sms传过去同时也写到了log里面带着键名,验证时我只需要把他拿出来就好了。

原创粉丝点击