Yii

One form and multiple models

∥☆過路亽.° 提交于 2019-12-25 08:16:13
问题 I am using Yii Framework. Purpose: Get user input and insert data into Order and OrderDetail tables on one form. The problem is data is inserted only into the Order table. I have tried to follow the wiki tutorial, but I can't fix this problem. Why can't I insert data into both tables, Order and OrderDetail ? I have five models: Customers(customer_id, customer_name, phone, email, lat, lng, ...) Products(product_id, product_name,price, ...) Order(order_id,customer_id, order_status, staff_id, ..

pretty url in yii2 not working

折月煮酒 提交于 2019-12-25 07:38:19
问题 In web.php i have this 'urlManager' => [ 'enablePrettyUrl' => true, 'showScriptName' => false, 'rules' => [ '<controller:\w+>/<action:\w+>' => '<controller>/<action>', '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>', '<controller:\w+>/<id:\d+>' => '<controller>/view', ], ], apache for this folder configured like this php.conf file <VirtualHost *:80> AssignUserId alexzander alexzander ServerName localhost DocumentRoot /home/alexzander/Dropbox/study/3year/2/php/ <Directory

Ignoring Server Down Error Message when using Yii CMemCache

给你一囗甜甜゛ 提交于 2019-12-25 07:22:24
问题 I've enabling yii memcached, How do I ignoring this error when dedicated memcached server was down. MemcachePool::get(): Server 192.168.1.200 (tcp 11211, udp 0) failed with: No connection could be made because the target machine actively refused it. (10061) Thanks, 回答1: You could: extend CMemCache as your own caching component override the getters and setters to return false if no connection is present or connection isn't active, otherwise call the parent:: equivalent method (with any

Yii: Can not Display Data in Grid View

末鹿安然 提交于 2019-12-25 07:16:28
问题 I can't list data in grid using yii framework. My controller is Sitecontroller.php , My view is list_jobseeker.php . I got the error: Parse error: syntax error, unexpected '*', expecting ']' in C:\wamp\www\yii_new\framework\base\CComponent.php(612) : eval()'d code on line 1 Anybody give any suggestion to correct these issue? My controller: public function actionlist_jobseeker() { $session_id=Yii::app()->session['user_id']; if ($session_id == "") { $this->redirect( array('/employee/site/login'

How to force a login using YII?

你离开我真会死。 提交于 2019-12-25 07:06:23
问题 I have a user that needs to authenticate his account via an OTP. TO authenticate, he fills in his OTP and it verifies the cellphone number. Once authenticated, I want to force him to log in. I.e. So he doesn't still have to manually login. So, for this form, I basically have: if($model->validate()) { // Force Login $this->redirect(array('/site/index')); } Using only one of his credentials (namely his cellphone number), I need to force him to login. How would I do that? 回答1: The procedure is

PHP converting UTC to Local Time

我与影子孤独终老i 提交于 2019-12-25 06:42:19
问题 In my postgresql, the I have the following column named "created" that has the type timestamp with timezone So I inserted the record according to the format as such which I believe is UTC. 2015-10-02 09:09:35+08 I am using php Carbon library so i did the following: $date = Carbon\Carbon::parse('2015-10-02 09:09:35+08'); echo $date->->toDatetimeString(); //gives result as 2015-10-02 09:09:35 How can I use the library to echo the correct timezone which includes the adding of the +8 in the above

Getting a particular row from database in yii

冷暖自知 提交于 2019-12-25 06:36:34
问题 I am working on a job site.And using Yii.I have gridview which list all the jobs posted by user,but I just want to show the jobs which are posted by a particular user.like if the user is logged in as admin then it should show only jobs posted by admin.I have tried the following things but not working. In Controller. //codes public function actionViewJob() { $user_id = Yii::app()->session['user_id']; /* For User Authentication */ if (Yii::app()->user->getId() === null) $this->redirect(array(

Yii Framework - yic migrate command doesn't work

﹥>﹥吖頭↗ 提交于 2019-12-25 05:24:16
问题 I am trying to create a table using Yii db migration in safeUp() method. However, when I use the "./yiic migrate" command, it runs successfully but the table doesn't appear in the database. The following is code from the migration file: <?php class m130808_123826_test_table extends CDbMigration { public function up() { } public function down() { echo "m130808_123826_test_table does not support migration down.\n"; return false; } public function safeUp() { $this->createTable('tbl_test', array(

Yii framework how update all records?

流过昼夜 提交于 2019-12-25 05:09:31
问题 I am using Yii framework. /view/update.php <?php echo CHtml::beginForm(); foreach ($items as $i=>$item): echo '<tr>'; echo '<td>'.$item['name'].'</td>'; echo '<td>'.$item['c1'].'</td>'; echo '<td>'. count(cos::model()->findAll(array( 'condition'=>'cos2='.$item['id'],))).'</td>'; echo '<td>'. CHtml::activeCheckBox($item, "[$i]c2").'</td>'; echo '<td>'. CHtml::activeCheckBox($item, "[$i]c3").'</td>'; echo '<td>'. CHtml::activeCheckBox($item, "[$i]c4").'</td>'; echo '<td>edit</td>'; echo '</tr>'

yii setflash not working in php [duplicate]

只愿长相守 提交于 2019-12-25 04:26:10
问题 This question already has answers here : yii setflash is not working when using redirect (4 answers) Closed 5 years ago . Hye there i have a problem i've design my website using yii framework and now when user register i want to show something like registration successful and redirect to log in page. Unfortunately it keep redirect to log in page without showing any message. Below is my code for user controller public function actionCreate() { $model=new User; // Uncomment the following line