Yii and Mysql Stored Procedures

I need to get results in mysql procedures and i need store too. I can use Yii 2 to do it? I know work with only criteria and active record to work using yii.

Hi, You can call the Procedure using the below function

public function actionView($param1, $param2)


    // sql query for calling the procedure

    $sql = "CALL get_country_and_states(:params_1, :params_2)";

    // passing the params into to the sql query

    $params = [':pamams_1'=>$pamam1, ':pamams_2'=>$pamam2];

    // execute the sql command

    return Yii::$app->db->createCommand($sql, $params)->queryAll();


using the same function(by sending the required update fields) you can update the records in stored procedure. Insdant of queryAll() you should use execute() to create/update the records.

Thanks. Worked very well