Quentinb
(Quentin)
February 17, 2015, 9:46am
1
Hi,
I have this code:
$companymodel = Company::findOne(1);
$companymodel->days_left = 45;
$companymodel->save();
It fails saying that the company email already exists? The error is correct based on my validations in the Company model, but should the code above not just do an update on the paid DB column and ignore the rest?
Quentinb
(Quentin)
February 17, 2015, 9:56am
2
Don’t worry, I changed to:
$companymodel = Company::find(1);
And working fine. Still need to get my head around find and findOne.
Quentinb
(Quentin)
February 17, 2015, 10:08am
3
And then I run into another error.
2015-02-17 10:07:16 [41.74.179.194][-][-][error][yii\base\UnknownPropertyException] exception 'yii\base\UnknownPropertyException' with message 'Setting unknown property: yii\db\ActiveQuery::days_left' in /usr/www/users/stariurbyb/vendor/yiisoft/yii2/base/Component.php:197
Stack trace:
#0 /usr/www/users/stariurbyb/controllers/PaymentController.php(26): yii\base\Component->__set('days_left', 45)
#1 [internal function]: app\controllers\PaymentController->actionNotifypayfast()
#2 /usr/www/users/stariurbyb/vendor/yiisoft/yii2/base/InlineAction.php(55): call_user_func_array(Array, Array)
#3 /usr/www/users/stariurbyb/vendor/yiisoft/yii2/base/Controller.php(151): yii\base\InlineAction->runWithParams(Array)
#4 /usr/www/users/stariurbyb/vendor/yiisoft/yii2/base/Module.php(455): yii\base\Controller->runAction('notifypayfast', Array)
#5 /usr/www/users/stariurbyb/vendor/yiisoft/yii2/web/Application.php(83): yii\base\Module->runAction('payment/notifyp...', Array)
#6 /usr/www/users/stariurbyb/vendor/yiisoft/yii2/base/Application.php(375): yii\web\Application->handleRequest(Object(yii\web\Request))
#7 /usr/www/users/stariurbyb/web/index.php(12): yii\base\Application->run()
#8 {main}
PLEASE help.
it seems you don’t have days_left in Company table or in Company model
Quentinb
(Quentin)
February 17, 2015, 10:24am
5
Thanks,
It is definitely in my Company table and this is in my model:
* @property integer $days_left
.
.
.
public function rules()
{
return [
[['days_left'], 'integer'],
I did create the controller class myself and not using the Gii tool. Could that be a problem?