[請益] 資料flush()後遺失欄位
大家好,小弟是PHP初學者,
最近練習使用symfony搭配doctrine時,
遇見無法正確寫入資料的問題。
public function registerAction()
{
$account = new Account();
$account->setUsername("eric");
$account->setPassword("777");
$account->setMoney("100");
$em = $this->getDoctrine()->getManager();
$em->persist($account);
$em->flush();
$accounts = $em->getRepository('AppBundle:Account');
$account = $accounts->findAll();
...
}
執行完撈回來的資料只有money有正確寫入,剩下的都是null。
但是最新的一筆卻又是正常的。
[{"id":1,"username":null,"password":null,"money":100},
{"id":2,"username":null,"password":null,"money":100},
{"id":3,"username":"eric","password":"777","money":"100"}]
另外如果不新增資料,直接去撈出來連最新一筆都會是失敗的。
{"id":3,"username":null,"password":null,"money":100}]
想請問問題可能出在哪?
-----------------------------------------
第一次在本版發問,
若問的方法或格式有問題再麻煩指正,謝謝!
附上log 與 整理過的網頁版
dev.log:
https://i.imgur.com/lq527oU.png

網頁版:
https://hackmd.io/s/H1i36t6fZ
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 122.117.36.235
※ 文章網址: https://www.ptt.cc/bbs/PHP/M.1497359371.A.EFA.html
※ 編輯: qweasd777 (122.117.36.235), 06/14/2017 00:09:43
→
06/14 10:00, , 1F
06/14 10:00, 1F
→
06/14 10:02, , 2F
06/14 10:02, 2F
→
06/14 10:14, , 3F
06/14 10:14, 3F

→
06/14 10:16, , 4F
06/14 10:16, 4F
→
06/14 19:45, , 5F
06/14 19:45, 5F
→
06/14 19:51, , 6F
06/14 19:51, 6F
PHP 近期熱門文章
PTT數位生活區 即時熱門文章