Yii

PHP before action and after action

陌路散爱 提交于 2019-12-25 01:47:08
问题 I would like to know how can I do something similar with beforeAction() and afterAction() from Yii. I need to have the same behavior in my PHP like those two functions from Yii and I don't know where to start from. What I really need in my case is that every time a function executes, it has to reload some parameters and after the function executes it's code, it has to set them again. The first action can be done in the constructor but the second one can only be done using a callback and this

Dependent dropdown list in yii returns empty string even after validation

房东的猫 提交于 2019-12-25 01:37:27
问题 I know this question might be familiar to most of you, but allow me to ask because most of the answers to related questions here in this forum and in YII forum have not been given a satisfactory answer. My two depended drop downs are working fine and the 2nd one gets populated based on the selection of the first one. All values are from the database. Now my problem is that, the second dropdown keeps on returning an empty value even after a value is selected and it doesn't seem to be validated

Create AccessRules in modules Yii Framework

ε祈祈猫儿з 提交于 2019-12-25 01:06:35
问题 in modules\administrator\components\AdminController: class AdminController extends CController { public function filters() { return array('accessControl'); } public function accessRules() { return array( array('deny', 'users' => array('*')), ); } } in modules\administrator\controllers\Sitecontroller: class SiteController extends AdminController { public function actionIndex() { $this->render('index'); } public function actionLogin() { $this->render('login'); } } but when visit mydomain.site

Send emails as a background process

南楼画角 提交于 2019-12-24 23:19:51
问题 I want to make a newsletter feature in my application. I need to send emails about 5000-6000 after I create a newsletter. When the newsletter is published it will create an email queue which will be stored in the database. Since it requires a lot of time I need to run it in the background. So I made a command to send the mail using YiiMailer and the email queue from the database. My command is working, but it is getting terminated after some time without completing the job. Also I need to run

What determines (how to configure) what format string is used by php PDO driver for values of date and timestamp fields?

倖福魔咒の 提交于 2019-12-24 23:04:07
问题 I have Firebird 3.0 database which have date and timestamp fields and I am using interbase extension (yes - still interbase) and Yii2 framwork in PHP 7.x. And I have Yii code: Yii::$app->db->createCommand('select order_date from orders where order_id=5'); which returns field with value: 2019-10-15 00:00:00 AFAIU then Yii2 uses PDO and that is why my question reduces to the question about PDO. PHP has DateTime extension but AFAIU PDO does not use DateTime class (and also does not use Unix

Retreving specific row from database in yii

岁酱吖の 提交于 2019-12-24 21:27:55
问题 I am working on a job site,And want to show only the jobs posted by a particular user in cgridview.My actuall aim is to authenticate the user so that only jobs posted by him/her will be visible in cgridview.I have done the following stuff,but not working. In controller: public function actionViewJob() { $user_id = Yii::app()->session['user_id']; /* For User Authentication */ if (Yii::app()->user->getId() === null) $this->redirect(array('site/login')); /* For User Authentication */ /* Have

Yii formatting date and filters

点点圈 提交于 2019-12-24 21:22:05
问题 I have an date field that need to be presented as day/month/year and saved as year-month-date. I thought in using CFilter for that but since it apply a function after the action it would be executed before the renderization. Should I put it on an event, is there a default approach for filtering input data and formatting the output data in yii? 回答1: The easiest way to do it is to pass your information to a CGridView / CDetailView as a type of date: 'columns'=>array( array( 'name'=>'checkout',

PHPUnit and Yii on a shared server

 ̄綄美尐妖づ 提交于 2019-12-24 20:26:31
问题 I have installed PHPUnit and checked my PEAR settings and everything went fine. I'm using Yii as my framework and I am on a linux shared server. When I run a test (any test) I get the errors below. From what I can tell I think I need to add the following to my path settings: /home/myname/php/ since that is where both the PHP and PHPUnit folders are located. I am unable to modify the php.ini file since I am on a shared server. I am wondering if this is really the problem and if anyone else has

Yii Get MySql query executed

泄露秘密 提交于 2019-12-24 19:09:18
问题 I need get the MySql query executed before Save, Update, Delete for create a personal LOG (audit). I use $model->save() and $model->delete() standard from CActiveRecord. Any know how i can do this? Thanks to all! 回答1: You can use the methods class Objects extends CActiveRecord { protected function beforeSave() { // Your code goes here } protected function beforeDelete() { // Your code goes here } } For Logging of query you refer this thread Logging u can also see the log on the page by just

How to prevent mysql injection when using mysql IN clause without activeRecord in Yii?

南楼画角 提交于 2019-12-24 18:04:36
问题 I have an array with ids that I get from client. And I want use those ids in my sql query with IN clause. But this query goes on a table that has no model. So there is no active record (criteria) query possible. ** Table userTasks ** -------------------- | idUser | idTasks | ---------+---------- | 1 | 1 | ---------+---------- | 1 | 2 | ---------+---------- | 1 | 3 | ---------+---------- First approach does not work because params are always considered as strings. So :tasks is a string '1,2,3'