Yii

Yii2 remove index.php from url

纵然是瞬间 提交于 2021-02-18 11:20:48
问题 When I set the option in Yii to remove index.php from the URL I get a 404 error and this error in the error logs File does not exist: /var/live/var . In my browser I get this error The requested URL /var/decat/frontend/web/index.php was not found on this server. but the file is exactly in that location. What might explain that is that my document root is /var/live and decat is an alias as shown in the conf file. This url works fine http://13.21.16.180/decat/index.php/site/login but when I

Filtering CGridView with CArrayDataProvider in Yii: how?

▼魔方 西西 提交于 2021-02-07 14:53:28
问题 I created a CGridView in Yii whose rows are read from an XML file. I'm not using any models: only a controller (where I read the file) and a view (where I display the grid). What I cannot create is a filter (one input field per column) in the first row of the grid so to visualize only certain rows. How can I do it? This is what I have until now: Controller: <?php class TestingController extends Controller { public function actionIndex() { $pathToTmpFiles = 'public/tmp'; $xmlResultsFile =

Filtering CGridView with CArrayDataProvider in Yii: how?

亡梦爱人 提交于 2021-02-07 14:52:55
问题 I created a CGridView in Yii whose rows are read from an XML file. I'm not using any models: only a controller (where I read the file) and a view (where I display the grid). What I cannot create is a filter (one input field per column) in the first row of the grid so to visualize only certain rows. How can I do it? This is what I have until now: Controller: <?php class TestingController extends Controller { public function actionIndex() { $pathToTmpFiles = 'public/tmp'; $xmlResultsFile =

Swift mailer attachment

我与影子孤独终老i 提交于 2021-02-07 07:57:10
问题 I have tried email extensions in yii twice. 1.YII-MAIL 2.PHP MAILER Now i would like to try out swift mailer.I have downloaded the package from here http://swiftmailer.org/download and added it to the extensions folder in YII. Here i have a form ,with fields for name,email,phone and an attachment. I am saving the file uploaded to a folder called resumes under images folder ,at the same time i am sending a mail with all details along with the uploaded file as an attachment .But on clicking

Swift mailer attachment

可紊 提交于 2021-02-07 07:56:12
问题 I have tried email extensions in yii twice. 1.YII-MAIL 2.PHP MAILER Now i would like to try out swift mailer.I have downloaded the package from here http://swiftmailer.org/download and added it to the extensions folder in YII. Here i have a form ,with fields for name,email,phone and an attachment. I am saving the file uploaded to a folder called resumes under images folder ,at the same time i am sending a mail with all details along with the uploaded file as an attachment .But on clicking

render a view from another controller, yii

别来无恙 提交于 2021-02-05 20:59:13
问题 The controller: controllers |-FooController.php |-BarController.php The views: view |-foo| | |-index.php | |-error.php | |-bar| |-index.php How to render the error.php view with an action of the bar controller? I have tried: $this->render('foo/error'); But it doesn't work. 回答1: try this $this->render('//foo/error'); 回答2: If you don't echo it , you will get a blank page. The correct way is <?= $this->render('//foo/error'); ?> or <?php echo $this->render('//foo/error'); ?> This also works for

Yii createCommand Update with bindValue

穿精又带淫゛_ 提交于 2021-01-28 07:45:59
问题 I'm using createCommand in Yii Framework and I want to know about use bindValue for the params, Ex: Yii::app()->db->createCommand() ->update('table', array( 'field'=>'$valuefield', ), 'id_table=:id_table', array(':id_table'=>$id_table)); In this case, the value of $valuefield and $id_table are protected? Or I should create the sql query manually and pass the parameters with bindValue? Thank you! 回答1: In this case, the value of $valuefield and $id_table are protected? Yes. Method update

How can validate either one of the textfields to be filled in Yii

爷,独闯天下 提交于 2021-01-28 06:46:10
问题 I'm new to Yii framework. Now in my form I have two fields FirstName and LastName. I want to validate such that either of the two is filled. i.e not both should be empty. Suppose the user leaves both the fields empty it should not allow submit. The user should atleast enter any of these fields. Rules public function rules() { return array( array('Firstname,Lastname, email, subject, body', 'required'), array('email', 'email'), array('verifyCode', 'captcha', 'allowEmpty'=>!CCaptcha:

What is the use of “defined('YII_DEBUG') or” in “defined('YII_DEBUG') or define('YII_DEBUG', false);”?

一个人想着一个人 提交于 2021-01-27 05:06:07
问题 In the defined('YII_DEBUG') or define('YII_DEBUG', false); line of code we are checking if debug has defined previously it will do nothing but if not it will set to false . I did not get this I mean what if we want to override previous value and why we cant simply do define('YII_DEBUG', false); why it necessary to check previous value if we don't want to use that? 回答1: I didnt do it but you are not clear about my question, we can only change the YII_DEBUG value in /web/index.php. one more

What is the use of “defined('YII_DEBUG') or” in “defined('YII_DEBUG') or define('YII_DEBUG', false);”?

扶醉桌前 提交于 2021-01-27 05:04:39
问题 In the defined('YII_DEBUG') or define('YII_DEBUG', false); line of code we are checking if debug has defined previously it will do nothing but if not it will set to false . I did not get this I mean what if we want to override previous value and why we cant simply do define('YII_DEBUG', false); why it necessary to check previous value if we don't want to use that? 回答1: I didnt do it but you are not clear about my question, we can only change the YII_DEBUG value in /web/index.php. one more