Yearly Archives: 2009

Extract from Doctrine_Record

/** * returns an array of modified fields and associated values * @return array * @todo What about a better name? getModifiedFields? */ public function getModified() { $a = array();   foreach ($this->_modified as $k => $v) { $a[$v] = $this->_data[$v]; } return $a; }   /** * REDUNDANT? */ public function modifiedFields() { $a […]

Posted in PHP, Symfony | Tagged , , | 2 Comments

Extending plugins in PHP and Symfony

Plugins are great but they are never what you exactly wanted. When they are designed properly, the best way to customize them is to extend them instead of directly editing them. Now, imagine I have:1 # Penguin.class.php class Penguin { public function __construct() { echo "Windows is bad\n"; } }# Penguin.class.php class Penguin { public […]

Posted in PHP, Symfony | Tagged , , , , , | Leave a comment

PHP serialization optimization

I recently had to use the serialize() function to store objects in Memcache. However, I realized that a lot of these objects (Propel objects precisely) were unnecessarily huge when stored: they had a lot of properties with quite long names having their default class value. That’s when I realized I could use the __sleep() function […]

Posted in PHP, Symfony | Tagged , , , , , | Leave a comment