阿江

阿江

这家伙有点懒,还没写个性签名!

  • 财富值16816
  • 威望值160
  • 总积分20276

个人信息

  • 2017-09-18 已签到
    连续签到1天,获得了5个金钱
  • 发布了话题
    [vim]左右字符交换,上下两行交换
  • 回复了 的回复
    public function prevCaptcha($attribute, $params)
    {
        $captcha = $this->createCaptchaAction();
        $value = $this->vcode;
        $valid = !is_array($value) && $captcha->validate($value, $this->caseSensitive);
        if (!$valid) {
            $this->addError($attribute, ErrorCode::ERROR_VCODE_NOT_MATCH);
        }
    }
    public function createCaptchaAction()
    {
    
        $ca = Yii::$app->createController($this->captchaAction);
        return $this->captchaAction;
        if ($ca !== false) {
            /* @var $controller \yii\base\Controller */
            list($controller, $actionID) = $ca;
            $action = $controller->createAction($actionID);
            $action->regenerateAfterValidation = false;
            if ($action !== null) {
                return $action;
            }
        }
        throw new InvalidConfigException('Invalid CAPTCHA action ID: ' . $this->captchaAction);
    }
    

    上面是重写的验证方法,总在下面这一步报错,有什么解决办法吗
    $ca = Yii::$app->createController($this->captchaAction);
    $this->captchaAction = 'api/article/captcha';

    报的什么错?

  • 你在/etc/php.d目录下看到mysql.ini文件了吗?有这个文件就可以加载mysql.so

  • 找不到mysql扩展的问题,你运行下面这条命令,重启web服务应该就可以了:

    [root php.d]# echo "extension=mysql.so">/etc/php.d/mysql.ini
    
  • 嗯,linux下是moudles,和windows下不一样,只有windows下才是ext。

  • centos中的扩展文件(ext)后缀是*.so
    在/etc/php.ini文件中要指定扩展文件(ext)所在目录:
    extension_dir="/usr/lib64/php/moudules"

  • 扩展模块都在/usr/lib64/php/moudules目录下。
    多说一句,扩展模块的配置文件一般都在/etc/php.d目录下。你可以去看看。

  • 2017-08-10 已签到
    连续签到1天,获得了5个金钱
  • //实例:客户端验证器
    文件位置:
    \advanced\frontend\components\validators\StatusValidator.php

    <?php
    namespace frontend\components\validators;
    use yii\validators\Validator;
    use frontend\models\Validator as v;
    class StatusValidator extends Validator{
        public function init(){
            parent::init();
            $this->message = '无效状态';
        }
        public function validateAttribute($model, $attribute){
            $value = $model->$attribute;
            if(!in_array($value,v::status())){
                $model->addError($attribute, $this->message);
            }
        }
        public function clientValidateAttribute($model, $attribute, $view){
    		/*
    		预定义的变量(可直接在JavaScript中引用):
    		attribute:正在被验证的属性名称
    		value:正在被验证的值
    		messages:一个数组,记录了与输入项对应的验证错误信息
    		deferred:一个数组,可以推入的推迟数组
    		*/
            $statuses = json_encode(v::status());
            $message = json_encode($this->message, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
            return <<<JS
    if ($.inArray(value, $statuses) === -1) {
        messages.push($message);
    }
    JS;
        }
    }
    

    文件位置:
    \advanced\frontend\views\post\validator.php

    	$form = ActiveForm::begin([
    	'enableClientValidation'=>true,
    ]);
    <?= $form->field($model, 'selectedDefault')->textInput(); ?>
    

    文件位置:
    \advanced\frontend\models\Validator.php

    <?
    	public function rules(){
    		return [
    			['selectedDefault',StatusValidator::className()],
    		];
    	}
    	public static function status(){
    		return ['ok','active','offline','online'];
    	}
    <?
    
副董事长 等级规则
20276/50000
资料完整度
10/100
用户活跃度
0/100

Ta的关注

2

Ta的粉丝

94

Ta的访客

248