Yii Framework Forum: Update Data Menggunakan Dao - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Update Data Menggunakan Dao Rate Topic: -----

#1 User is offline   arief 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 03-August 09

Posted 04 April 2013 - 07:27 PM

dear all, gimana solusi untuk masalah berikut.

ini code di controller
$sql = 'select sum(tbl_detail_order.price) from tbl_detail_order where tbl_detail_order.order_id=:id';
$cmd = Yii::app()->db->createCommand($sql);
$cmd->bindValue(":id",$id,PDO::PARAM_STR);
$amount=$cmd->query();
      
$sql='update tbl_order set tbl_order.amount=:amount,tbl_order.order_status=1 where tbl_order.id=:id';
$cmd = Yii::app()->db->createCommand($sql);
$cmd->bindValue(":id",$id,PDO::PARAM_STR);
$cmd->bindValue(":amount",$amount,PDO::PARAM_STR); // line yang bermasalah
$cmd->execute();


error yang ditampilkan

Quote

Object of class CDbDataReader could not be converted to string (C:\xampp\htdocs\sales\yii\framework\db\CDbCommand.php:277)


thanks
0

#2 User is offline   Hermans 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 201
  • Joined: 17-February 11

Posted 12 April 2013 - 02:43 AM

kalau dilihat dari errornya itu masalah waktu konversi ke string. bukankah amount itu numeric, dan seharusnya adalah:
$cmd->bindValue(":amount",$amount,PDO::PARAM_INT); // line yang bermasalah

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users