$cnpp = cnplanpriceTable::getOneByPlan('A_PP_FREE1');
$ads = cnadTable::getInstance()
->createQuery()
->andWhere('userid = ?', 1107924)
->andWhere('hw_pay_plan LIKE ?', '%A_PA_FREE1%')
->execute([], Doctrine::HYDRATE_ON_DEMAND);
$this->log('Found ' . count($ads) . ' ads');
foreach ( $ads as $cnad )
{
$cnad->setPlan($cnpp);
$cnad->save();
$cnexp = cnexpirationTable::getItem($cnad, 'ad_plan');
$cnexp->setValue('A_PP_FREE1');
$cnexp->save();
$this->log('Processed ' . $cnad->getLinkId());
}