0
我想打印我执行的存储过程的结果。打印存储过程中的值yii2
这是我试过的代码:
public function actionGetdata($tranId) {
$model = new ReceivedGoodsDetail();
// $model = $this->findModel($tranId);
$connection = \Yii::$app->db;
$transaction = $connection->beginTransaction();
//set nilai default
$model->ID_Received_Goods = $tranId;
if ($model->validate()) {
$connection = Yii::$app->db;
$command = $connection->createCommand('{call usp_T_Sales_Inventory_Detail#SelectData(:ID_Received_Goods)}');
$ID_Received_Goods = $model->ID_Received_Goods;
$command->bindParam(":ID_Received_Goods", $ID_Received_Goods, PDO::PARAM_STR);
$isSuccess = 0;
if ($command->execute()) {
$transaction->commit();
$isSuccess = 1;
} else {
$transaction->rollBack();
$isSuccess = 0;
}
return [
'data' => $isSuccess
];
} else {
$isSuccess = 0;
return [
'data' => $isSuccess,
'error' => $model->getErrors(),
];
}
}
当我尝试这RESTClient实现的结果是
<response>
<data>1</data>
</response>
,而我想要的结果将显示
结果select *
from T_Received_Goods_Detail
where ID_Received_Goods = 'RG/1608/11'
请帮忙。
为什么它会显示'select * from T_Received_Goods_Detail的结果,其中ID_Received_Goods ='RG/1608/11''当您设置'$ isSuccess = 1;'&'$ isSuccess = 0;'并返回数据'=> $ isSuccess,'。所以,它会打印'1'或'0'。它打印'1'很好。意思是,它正在执行你的查询。 –
我想看到的结果从执行该查询, 例如: ' -
RG /一分之一千六百○七 ID_Received_Goods> 158 ID_Detail_Received_Goods> ITEM-0002 管理员 insert_user> 2016年7月28日10:36:50.910 insert_date> 管理员 update_user> 2016年7月28日10:36:50.910 UPDATE_DATE> ' –
Allegra
你想我知道。但是,你在哪里编写了获取选定数据的代码? –