Yii2 如何将存储过程的数据呈现到更新';类型
如何将存储过程的“数据”呈现到更新表单,并将create表单的数据发送到存储过程 控制器:Yii2 如何将存储过程的数据呈现到更新';类型,yii2,Yii2,如何将存储过程的“数据”呈现到更新表单,并将create表单的数据发送到存储过程 控制器: 对于我使用的索引表: public function actionIndex(){ return $this->actionListar(); } public function actionListar(){ $listadoClientes = $gestor->listar(); //listar() is the sp $provider
对于我使用的索引表:
public function actionIndex(){
return $this->actionListar(); }
public function actionListar(){
$listadoClientes = $gestor->listar(); //listar() is the sp
$provider = new ArrayDataProvider([
'allModels' => $listadoClientes,
'key' => 'IdPersona',
]);
return $this->render('index', [
'dataProvider' => $provider,
]);
}
对于我使用的视图:
public function actionView($id) {
$detallesCliente = $this->actionDame($id);
return $this->render('view', ['dataProvider' => $detallesCliente,]);...
}
public function actionDame($IdPer)
{
$gestor = new Clientes();
$detallesCliente = $gestor->dame($IdPer);
return $detallesCliente;
}
视图:Index.php:
<?= GridView::widget([ 'dataProvider' => $dataProvider,'columns' => 'Apellidos',...], ]); ?>
Views.php
<?= DetailView::widget(['model' => $dataProvider,'attributes' => [
[label' => 'Apellidos',
'value' => ArrayHelper::getValue($dataProvider, 'Apellidos'),
],
]); ?>
解决方案是在调用存储过程的方法末尾添加以下内容:
$result= $query->queryOne();
$this->setAttributes($result);