문제

I am using PHP, Zend and MySql.

I need to change the value of some rows in a result set. I tried using foreach but I found out that the changes won't persist outside the foreach block, and I couldn't find a way to get the result set's number of rows so I can use a for.

This is what I tried:

$datas = $this->getClientes($search);

    foreach ($datas as $row) {
        if($row['dt_pagamento'] != NULL && $row['valor_pago'] == NULL)
            $row['valor_pago'] = $this->PesquisaBoletoCorreto($row['id_parcela']);
}

getClientes returns a result set. PesquisaBoletoCorreto changes the result set's value.

도움이 되었습니까?

해결책

Try this:

foreach ($datas as $key => $row) {
    if($row['dt_pagamento'] != NULL && $row['valor_pago'] == NULL)
        $datas[$key]['valor_pago'] = $this->PesquisaBoletoCorreto($row['id_parcela']);
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top