The problem I met is in a table that there is a NOT NULL column. But the UI(view) does not have the input field for this column. When it comes to the SaveAll(this->data) call in the corresponding controller's action method, the field is missing in this->data. Thus the SQL statement generated does not include this column. So the saving fails with an error: 1364: Field 'xyz' doesn't have a default value.
The real frustrating part of the problem is that this error only happens on my local laptop. And it does not happen on the server. The following is the configuration of my local laptop and the server.
- server: CentOS 6.3, Nginx 1.2.4, MySQL 5.5.28, PHP 5.4.8, CakePHP 1.3.7
- my laptop: Windows 7, IIS 7.5, MySQL 5.6.11, PHP 5.4.15, CakePHP 1.3.7
I have two questions:
- Could I upgrade CakePHP from 1.3.7 to 1.3.16 by replacing only the cake folder? Is there any easy way to upgrade to 2.3.5? I see 2.x has better support for debugging. I am surprised to see this project is still using such an old version.
- How could I address the error mentioned above? Definitely I could add code to check and fill such NOT NULL column with a default value, or just define a default value in MySQL database. But there are other tables/columns with the same problem. Why does it NOT happen on the server? I want to find out the root cause of it before I set out to find a solution. I suspect it's related with the configuration either in environment (OS, MySQL, PHP etc.) or in my app code. Is there any best practices to overcome this? I searched around for a few days, but can't find anything much helpful to my problem. So it should not be a common problem. Or maybe just my search technique is really poor.
I am new in PHP and CakePHP, so any guidance/direction would be very helpful.
Thanks for any help in advance!
Zhu Ming
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment