CDbException

CDbCommand failed to execute the SQL statement: SQLSTATE[HY000]: General error: 1364 Field 'discount_type' doesn't have a default value. The SQL statement executed was: INSERT INTO `cart` (`is_finished`, `user_id`, `date`) VALUES (:yp0, :yp1, :yp2)

/home/gotham/public_html/library/db/CDbCommand.php(358)

346         {
347             if($this->_connection->enableProfiling)
348                 Yii::endProfile('system.db.CDbCommand.execute('.$this->getText().$par.')','system.db.CDbCommand.execute');
349 
350             $errorInfo=$e instanceof PDOException ? $e->errorInfo : null;
351             $message=$e->getMessage();
352             Yii::log(Yii::t('yii','CDbCommand::execute() failed: {error}. The SQL statement executed was: {sql}.',
353                 array('{error}'=>$message, '{sql}'=>$this->getText().$par)),CLogger::LEVEL_ERROR,'system.db.CDbCommand');
354 
355             if(YII_DEBUG)
356                 $message.='. The SQL statement executed was: '.$this->getText().$par;
357 
358             throw new CDbException(Yii::t('yii','CDbCommand failed to execute the SQL statement: {error}',
359                 array('{error}'=>$message)),(int)$e->getCode(),$errorInfo);
360         }
361     }
362 
363     /**
364      * Executes the SQL statement and returns query result.
365      * This method is for executing an SQL query that returns result set.
366      * @param array $params input parameters (name=>value) for the SQL execution. This is an alternative
367      * to {@link bindParam} and {@link bindValue}. If you have multiple input parameters, passing
368      * them in this way can improve the performance. Note that if you pass parameters in this way,
369      * you cannot bind parameters or values using {@link bindParam} or {@link bindValue}, and vice versa.
370      * Please also note that all values are treated as strings in this case, if you need them to be handled as

Stack Trace

#2
+
 /home/gotham/public_html/application/models/database/Cart.php(48): CActiveRecord->save()
43     private static function createCart($user_id = 0)
44     {
45         $cart = new self();
46         $cart->user_id = $user_id;
47         $cart->date = date("Y-m-d H:i:s");
48         $cart->save();
49         Yii::app()->user->setState('CartID', $cart->id);
50 
51         return $cart;
52     }
53 
#3
+
 /home/gotham/public_html/application/models/database/Cart.php(40): Cart::createCart(0)
35                 }
36                 return $model;
37             }
38         }
39 
40         return self::createCart($user_id);
41     }
42 
43     private static function createCart($user_id = 0)
44     {
45         $cart = new self();
#4
+
 /home/gotham/public_html/application/controllers/CartController.php(24): Cart::getCart()
19         ));
20     }
21 
22     public function actionAdd($id)
23     {
24         $cart = Cart::getCart();
25         $cart->addProduct(Product::model()->findByPk($id));
26         $_SESSION['cart_state'] = Cart::_ADD_;
27         $this->redirect('/cart');
28     }
29 
2024-03-28 23:14:50 Apache Yii Framework/1.1.14