Zend Framework longtext bug
Thursday, September 4th, 2008 | Coding, Technology | No Comments
There seems to be a bug in the 1.5.* versions of the Zend Framework outlined here which prevents the reading of longtext and longblog fields using the MySQLi DBMS. When attempting to retrieve data from these types of field a PHP fatal exception is thrown, similar to the one below:
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 4294967296 bytes) in /Zend/Db/Statement/Mysqli.php on line 227
That’s 4GB of data that PHP is attempting to allocate for just one longtext lookup for one database row! Obviously something serious has gone wrong here. However, fortunately the solution is quite straight-forward, upgrade to a later release of the framework. Nice and easy - at the time of writing this is version 1.6.
JavaScript setDate order
Wednesday, September 3rd, 2008 | Coding, Technology | 1 Comment
I came accross a very confusing error in my code the other day which, as is usually the case, was quite simple to sort out. The problem crept in when I was setting the year, month and day on a Javascript date object, like so:
-
var date = new Date();
-
date.setDate(31);
-
date.setMonth(9);
-
date.setFullYear(2008);
When alerting the date object I would get a string with the correct month and year but with the incorrect day - it would be set to the 1st instead of the 31st. The reason this occurred is because when you create a new date object, by default it is set to the current date and time. Now, as I was doing this in September, which only has 30 days, it was causing an error. The solution is quite simple: set the year first, then the month and finally the day:
-
var date = new Date;
-
date.setFullYear(2008);
-
date.setMonth(9);
-
date.setDate(31);