just got my first patch accepted in Zend Framework trunk ! thanks @ralphschindler for cleaning it up and commiting

About a year and a hlaf ago I submitted a small patch to the Zend Framework, http://framework.zend.com/issues/browse/ZF-9577 , great to see that if has now been commited in and will be in the next 1.11 release

thanks to @ralphschindler for cleaning it up and writing the test http://framework.zend.com/code/comp.php?repname=Zend+Framework&compare[]=/@24411&compare[]=/@24412

PHP int filter, Facebook user IDs, and 32 bit servers dont mix

just working on a facebook app and wondering why is it always inserting the Facebook user ID as 2147483647 when the ID is something else.

I've been using the (int) filter as detailed in th the zend framework docs and examples, but as Facebook user IDs are larger than the largest integer a 32 bit server can handle so (int) doesn't work Simple solution if your such on a 32 bit server is just to use 'is_numeric'

$id = is_numeric($id) ? $id : ''; // makes Facebook IDs work on 32bit

Filed under  //

PHP: Strip null entries from an array : how to

For a while i've had issues with certain db update queries in php - particularly where image uploads are involved

My original code looked like

but using the above code would over write the image fields in the db if the user didn't upload a new image

to get around this problem i wrote a is_null check on the image fields and pretty much write the $data array twice - once with the image fields and once without
- as i couldn't put php code in the middle of the array
- this is a pretty crappy solution so i sat down and figured out a simple way to strip null entries from an array - see code below

now i don't need to write the $data array twice - i can just use

$this->update(strip_null_array_entries($data), 'id = '. (int)$id);

Filed under  //