使用phalcon orm更新所有结果集

时间:2017-04-11 04:50:01

标签: resultset phalcon

我尝试立即用phalcon orm更新所有结果集。像这样:

foreach ($packages as $package) {
                $rates =  $package->getRates();
                $package->rates = $rates;
                $package->update();
                $packageHistory = PackageHistories::find('rates = 0 AND package_id = '.$package->id);
                $packageHistory->rates = $rates;
                $packageHistory->update();
            }

但它不起作用。应该怎么样?

1 个答案:

答案 0 :(得分:0)

答案:

foreach ($packages as $package) {
   $rates =  $package->getRates();
   $package->rates = $rates;
   $package->update();
   $packageHistory = PackageHistories::find('rates = 0 AND package_id = '.$package->id)->update(array('rates' => $rates));
}