0

Here is my controller::

public function actionCreateGRN($id){
            $model = new VwPurchaseordhd;
            $sql = sprintf("call sp_im_CreateGRN(%s,'%s')",
                   $id,
                   $insertuser = Yii::app()->user->name
                );
           $command  = Yii::app()->db->createCommand($sql);
           $result = $command->queryAll();

         $this->redirect(array('grndetail/create', 'id'=>$model->id, 'pp_purordnum'=>$pp_purordnum, ));
    }

In $result I have an array:: Array ( [0] => Array ( [pp_purordnum] => PO1400000291 [vGrnNumber] => GR14007320 ) )

I need to pass array data via "redirect" to another controller/function. It's showing ERROR undefined pp_purordnum. I am missing something.

Could you please help me to pass parameter what I have in array ? Thanks in Advance.

SOLVED

Controller

        public function actionCreateGRN($id){
            $sql = sprintf("call sp_im_CreateGRN(%s,'%s')",
                   $id,
                   $insertuser = Yii::app()->user->name
                );
           $command  = Yii::app()->db->createCommand($sql);
           $result = $command->queryRow();

           $pp_purordnum = $result['pp_purordnum'];
           $vGrnNumber = $result['vGrnNumber'];

         $this->redirect(array('grndetail/create', 'pp_purordnum'=>$pp_purordnum, 'vGrnNumber'=>$vGrnNumber, ));
    }
0

1 Answer 1

2
   $sql = "call sp_im_CreateGRN(:id, :user_name)"
   $command  = Yii::app()->db->createCommand($sql);
   $result = $command->queryAll(true, array(
       ':id'=>$id, 
       ':user_name'=>Yii::app()->user->name,
   ));
Sign up to request clarification or add additional context in comments.

1 Comment

I found the solutions. and updated the code below the question.. thanks for your answer. I will need your code. It's really great ... please vote this question

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.