Archive

Archive for the ‘PHP’ Category

Non-existant fields Zend_Db_Table_Abstract

December 20th, 2008

I'd run into a problem in the Zend Table where when inserting data from a form, if a field didn't exist in the database ZF would crap out with an exception. Having to unset posted variables I didn't need, meant more typing, more typing meant more unnecessary code.

I found the easiest way to get around this is by overriding the insert method in my extended App_Db_Table_Abstract class. Here's what my new insert method looks like.

  1. public function insert($data, $skip = true){
  2.  
  3. if($skip === true){
  4. $oldData = $data;
  5. $data = array();
  6. foreach($this->info('metadata') as $key => $value){
  7. if(isset($oldData[$key])){
  8. $data[$key] = $oldData[$key];
  9. }
  10. }
  11. }
  12.  
  13. parent::insert($data);
  14.  
  15. }

The method takes two parameters, the data ($data) and a Boolean value ($skip). Skip defaults to true, so I don't need to add this parameter to every call to insert, it's also there in case I don't want to skip my data.

It then iterates through the table meta data, which contains the field names for the table, checks to see if the key exists in the data from the form. If the field exists in the array then it's added to the new data array.

Finally the parent insert method is called, bobs your uncle.

In case you're wondering, I've subclassed some of the Zend classes, this allows me to override methods to my liking.

PHP, Zend Framework ,

Meta Data

December 19th, 2008

Over at fishrod we're developing our new CMS based on the new Zend Framework 1.7 (biting our nails for 2.0 to be released so we can relax for at least 3 months). One of the issues that always arises when developing a Content Management System for our clients is the amount of flexibility we want to offer them, and how generic the CMS has to be whilst still being flexible.
Read more...

PHP , ,

Agile Development

December 8th, 2008

Working at Channel 4 I've been introduced to Agile Development, to sum it up in one sentence...

"It's a way of working in a development team, where the specification for a project is constantly changing and the waterfall approach (you get a spec, build to it over a long period of time, get feedback and make amends) just doesn't cut it."

It's a completelty different way of working, and it's full of terms which I would say were thought up by some drunk developer, introducing words such as "brown bag".
Read more...

Development Strategies, Javascript, PHP , ,

Zend_Acl Db Storage

July 25th, 2008

I've spent the last few hours trying to extend Zend_Acl_Role_Registry and Zend_Acl to support Db storage, when it just hit me what I'm actually trying to do, and a much easier way to do it!
Read more...

PHP, Zend Framework , ,

Zend Framework and DoJo

July 23rd, 2008

I pretty much wet my self when ZF announced that they'd be integrating Dojo with the next iteration, and low and behold the first RC was made publicly available a few days ago. I literally dived in head first today, only to find the documentation was some what lacking.

I don't think the documentation is quite complete, but hats off to ZF for taking a step in the right direction.

Here's a quick tutorial on using Dojo's container's and pane's with ZF. I've added line breaks so it fits into the old blog.

Read more...

Dojo, Javascript, PHP, Zend Framework , , , ,