/** * 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() { [...]
Yearly Archives: 2009
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"; } } # Herd.class.php class Herd [...]
Posted in PHP, Symfony Tagged autoloading, inheritance, monkeypatching, PHP, plugins, Symfony 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 memcached, performance, PHP, propel, serialization, Symfony Leave a comment