Object Of Class Cdbdatareader Could Not Be Converted To Int

hi guys

i have problem "Object of class CDbDataReader could not be converted to int "

 public function actionTake() {

 $model = new Barang('create');

if (isset($_POST['Barang']['KodeBarang'])) {

             //$_POST['Materiil']['lokasi'] = $model->lokasi;

             $model->attributes = $_POST['Barang'];

             (int)$b = $_POST['Barang']['jumlah'];

             $sql1 = 'SELECT Stock FROM barang WHERE KodeBarang ="'. $_POST['Barang']['KodeBarang'] . '"';

             $dbcomand = Yii::app()->db->createCommand($sql1)->query();


             $data = (int)$dbcomand;


             $tampung = $data - $b;

             $sql = 'UPDATE barang SET Stock=' . $tampung . ' WHERE KodeBarang="' . $_POST['Barang']['KodeBarang'] . '"';

             $dbs = Yii::app()->db->createCommand($sql);






         $this->render('take', array('model' => $model));


what i should did to fix that problem, :unsure:

First of all, your code is vulnerable to sql injection.

And yes, this error caused by your attempt of converting object (returned by ‘query’ call) to int.

Read the docs.

what docs i should read ???

sorry i’m newer in yii…could you help me ??