我正在做一次正常的咨询,我已多次做过,但这是我第一次看到这个错误。
queryTransacao-> id变量(上面)返回'尝试获取非对象的属性'。
Foreach&查询 - 控制器:
foreach ($ this-> input-> post ('check') as $ key) {
$ queryTransacao = $ this-> boletos-> get_TransacaoIdbyCartao ($ key) -> result ();
$ this-> boletos-> update_transacoes_inclusao_boleto ($ dadosTransacoes, $ queryTransacao-> id);
}
通过知识,模型:
public function get_TransacaoIdbyCartao ($ numero_cartao = NULL) {
$ this-> db-> select ('id, valor_transacao, plano_pagamento, created_at');
$ this-> db-> where ('numero_cartao', $ numero_cartao);
$ this-> db-> where ('plano_pagamento', '01'); //?
return $ this-> db-> get ('bc_transacoes');
}
我尝试了$queryTransacao['id']
,但它返回了一个未定义的索引。
答案 0 :(得分:0)
按照给定的方式使用。
foreach ($ this-> input-> post ('check') as $ key) {
$result = $ this-> boletos-> get_TransacaoIdbyCartao ($ key) -> result();
foreach($result as $queryTransacao ){
$ this-> boletos-> update_transacoes_inclusao_boleto ($ dadosTransacoes, $queryTransacao-> id);
}
}
答案 1 :(得分:0)
在您的控制器上
foreach ($ this-> input-> post ('check') as $ key) {
$ queryTransacao = $ this-> boletos-> get_TransacaoIdbyCartao ($ key) -> result ();
if(count($ queryTransacao)>0)
{
foreach($ queryTransacao as $data){
$ this-> boletos-> update_transacoes_inclusao_boleto ($ dadosTransacoes, $data-> id);
}
}
}