作者qweasd777 (qweasd777)
看板PHP
标题[请益] 资料flush()後遗失栏位
时间Tue Jun 13 21:09:26 2017
大家好,小弟是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://webptt.com/cn.aspx?n=bbs/PHP/M.1497359371.A.EFA.html
※ 编辑: qweasd777 (122.117.36.235), 06/14/2017 00:09:43
1F:→ rickysu: 请自行开启 debug tool bar,看发生什麽事吧。 06/14 10:00
2F:→ rickysu: 你可以透过 /_profiler/ 去观看 06/14 10:02
4F:→ g9308370: 可以尝试看看把column name也加进@ORM\Column 06/14 10:16
5F:→ qweasd777: 後来在专案上照g93大的方法成功了,十分感谢~ 06/14 19:45
6F:→ qweasd777: 也谢谢ricky大的提示 好强的功能 以後会多加利用 06/14 19:51