[Solar-talk] Changes afoot: a new Model class

Paul M Jones pmjones at ciaweb.net
Wed Feb 7 19:30:38 PST 2007


Hi Andreas,

>> Let's take the "generate a thumbnail" example.  You could do that on
>> save() in the Model, automatically (note that save() calls insert/
>> update depending on the presence of a primary key value in the  
>> data) ...
>>
>>      class Vendor_Model_Images extends Solar_Sql_Model {
>>          public function insert($data)
>>          {
>>              $result = parent::insert($data);
>>              // create the thumbnail image based on new data
>>              $this->_createThumbnail($result);
>>          }
>>
>>          public function update($data, $where)
>>          {
>>              $result = parent::update($data);
>>              // update the thumbnail image based on new data
>>              $this->_updateThumbnail($result);
>>          }
>>
>>          protected function _createThumbnail($data)
>>          {
>>              // ...
>>          }
>>
>>          protected function _updateThumbnail($data)
>>          {
>>              // ...
>>          }
>>      }
>
> Yikes, this is probably very good for performance, but it might not  
> be so intuitive?

Maybe not.  :-(  While it seems intuitive to me, what I think makes  
sense is very often not so to others.  ;-)


>> Does that help at all?  If not, happy to talk more.  :-)
>
> Yes and no - I have gained a little more insight now, and I see how  
> the problem with late static binding makes this slightly  
> complicated. However, DB_DataObject seems to solve this relatively  
> elegantly and follows the active record pattern nicely. I am  
> assuming you are familiar with DBDO, but if not it might be worth  
> taking a look at how they solved this? (nevermind that it's huge  
> and slow and contains lots of deprecated code). There is a quick  
> and informative rundown on it here: http://wiki.cc/php/? 
> title=DB_DataObject#Basic_usage

"Huge and slow" indeed.  :-(  I looked at it a long time ago (3-4  
years) and even then it seemed kind of unwieldy to me.  But it's  
possible I have learned something in that time that will cause me to  
understand it better, so I'll take another look at it.  Thanks for  
reminding me of its existence.  :-)



--

Paul M. Jones  <http://paul-m-jones.com>

Solar: Simple Object Library and Application Repository
for PHP5.  <http://solarphp.com>

Join the Solar community wiki!  <http://solarphp.org>

Savant: The simple, elegant, and powerful solution for
templates in PHP.  <http://phpsavant.com>




More information about the solar-talk mailing list