草庐IT

php - Yii::app()->name 是否缓存在 yii 上?

Yii::app()->name是否缓存在yii上?经常使用它好吗?我决定在我的布局上使用自定义页面标题,并在我的Controller上使用类似这样的东西。$this->pageTitle=Yii::app()->name.":".$action 最佳答案 它不是cached缓存的,但是你想怎么用就怎么用。来自theguide:Theapplicationobjectisinstantiatedasasingletonbytheentryscript.Theapplicationsingletoncanbeaccessedatany

php - Yii 下拉列表使用 $form-> dropdownlist

我想从2个不同的模型创建一个表单,第一个是国家,第二个是文件。问题是我无法制作下拉列表,我总是遇到错误。这是代码,首先是我的controller.php部分$model=newCountry;$model2=newProduct;$this->performAjaxValidation(array($model,$model2));if(isset($_POST['Country'],$_POST['Product'])){//populateinputdatato$modeland$model2$model->attributes=$_POST['Country'];$model2-

php - 使用 Yii 自动存储日期时间

我开始使用Yii学习php,我有一个很大的问题,也许你可以帮助我。我正在使用表单来创建用户。我想将我在表单中引入的用户数据存储到数据库(MySQL)中,但我还必须将日期和时间存储在数据库的日期时间字段中。我看到了一些像CJUIDATEPICKER这样的扩展来选择日期,但我不知道有任何扩展来选择日期时间。我认为更好的方法是在创建新用户时自动存储日期时间。现在我在表单中有一个文本框,我必须在其中引入格式为yyyy-mmmm-ddddhh:mm:ss的日期时间,但我认为它没有用。拜托,有人可以帮助我并向我解释当我在数据库中创建寄存器时如何存储日期时间吗?非常感谢。编辑:现在我使用“$mode

php - 如何使用 php 提交 github

我想使用PHP代码添加并提交到本地git存储库我是github新手,所以github上的路径不太懂路径git.exe在C:\Users\Administrator\AppData\Local\GitHub\PortableGit_054f2e797ebafd44a30203088cd3d58663c627ef\libexec\git-corerepo路径C:\Users\Administrator\Documents\GitHub\confre$path="C:\Users\Administrator\Documents\GitHub\confre";chdir($path);echo

php - 为什么多个场景在 Yii 中不起作用?

我在我的应用程序中使用了多个场景,但遇到的问题是每次最后一个场景都会覆盖第一个场景。型号:publicfunctionrules(){returnarray([...]array('cost_spares','cost_spare_func','match','pattern'=>'/^[a-zA-Z]+$/','message'=>'Donotenterzeroor/andcharactersforSpareparts!','on'=>'cost_spare_func'),array('cost_labour','cost_labour_func','match','pattern'

php - Yii2 迁移向表中添加新列

使用Yii2中的迁移功能,我试图在表'users'上添加一个名为'authorization_key'的新列。我的up-函数如下:我最初的run函数是这样的publicfunctionup(){$this->createTable('users',['id'=>'pk','username'=>'stringUNIQUE','password'=>'string']);}当我运行./yiimigrateup在./yiimigrate/create之后,表被创建了。但是在添加$this->addColumn('user','authorization_key'for','stringUN

php - 在 Yii 2 中错误验证模式匹配有问题

我的rules方法中有一堆验证规则,所有错误似乎都有效,但这个有问题:['username','match','pattern'=>'/[a-zA-Z0-9_-]+/','message'=>'Yourusernamecanonlycontainalphanumericcharacters,underscoresanddashes.'],它验证,这是不正确的行为。我是不是做错了什么? 最佳答案 这个模式只检查第一个字符。您需要像下面这样更正它:['username','match','pattern'=>'/^[a-zA-Z0-9_

php - Yii 2.0 $request->post() 问题

在我的Controller中有以下几行$request=Yii::$app->request;print_r($request->post());echo"version_nois".$request->post('version_no',-1);输出如下Array([_csrf]=>WnB6REZ6cTAQHD0gAkoQaSsXVxB1Kh5CbAYPDS0wOGodSRANKBImVw==[CreateCourseModel]=>Array([course_name]=>test[course_description]=>kjhjk[course_featured_image]=

php - 在 header php 中使用 x-auth-token 发送请求

如何在YII中使用header将“x-auth-token”参数发送到服务器。我有这个代码$data=array('customerId'=>$userId);$getdata=http_build_query($data);$options=array('http'=>array('method'=>'GET','header'=>"Content-type:application/x-www-form-urlencoded\r\n"."Authorization:x-auth-token".$token."\r\n",'content'=>$getdata));$context=s

php - Yii2 始终使用 $_COOKIE、$_SESSION 和 $_SERVER 记录应用程序类别(类别过滤器无法正常工作)

我是Yii2的新手,我需要在一些操作发生后手动记录到数据库。对我来说最好的事情是按类别过滤。问题是Yii2总是添加带有信息$_COOKIE、$_SESSION和$_SERVER的额外行。这是正常的吗?如何禁用额外的日志行?这是前端配置return['id'=>'app-frontend','basePath'=>dirname(__DIR__),'bootstrap'=>['log'],'controllerNamespace'=>'frontend\controllers','components'=>['user'=>['identityClass'=>'common\models