There are two Mysql(5.1.73) tables, tableA and tableB. I want to insert three records into tableB when I have insert a record into tableA.So I used afterCreate method
public function afterCreate()
{
$info = json_decode($this->getInfo(),true);
foreach ($info as $key => $val) {
$log = new BdLogs();
$log->setBdLotteryId($this->getId());
$log->setCode($this->getCode());
$log->setMode($val['mode']);
$log->setWeis($val['weis']);
$log->setMark($val['mark']);
$log->setMoney($val['money']);
$tmp = explode('_', $val['account']);
$log->setAccount($tmp[1]);
$log->setBdSiteId($tmp[2]);
$log->setBdClentId($tmp[3]);
$log->setBdUserId($this->getBdUserId());
$log->setCreated(date('Y-m-d H:i:s'));
$log->setDetail($val);
$log->setStatus(0);
//print_r($log->toArray()); it is right!!!
try {
$log->save();
} catch (Exception $e) {
throw new Exception($e->getMessage());
}
}
}
But it doesn't work and doesn't have Exception,I don't know why? i use Phalcon 1.3
Please help me, Thanks!
It's solved!!! because the field created's type is time(),but I give datetime()