You are here:Home
  • Narrow screen resolution
  • Wide screen resolution
  • Decrease font size
  • Default font size
  • Increase font size
  • default color
  • green color
  • blue color

RapidPHP

In this category we should you how easily you can extend Zend Framework with your own classes and functions RapidPHP is a companion library for Zend Framework. It is under active development and will feature a number of unique components that ease development of your projects

Getting MIME of remote file with Zend Framework

Friday, 09 April 2010
If you ever need to get content type of remote file from within PHP, this class will come in handy. Supposing you need to check external link if it is an mp3 file. You will be able to do this: $sniffer = new Smartycode_Http_Mime();
$contentType = $sniffer->getMime($url);
if('audio/mpeg3' == $contentType) echo 'It is MP3';
Last Updated ( Friday, 09 April 2010 )

How to Download

Wednesday, 30 December 2009
This is placeholder

Database aware Select elements for Zend_Form (or Extending Zend_Form_Element_Multi)

Monday, 09 February 2009

In this article, you will know how you can extend select form element that comes with Zend Framework, to be easily filled with data from your database table. We want to be able to easily fill select elements from database table with less repetitive code. It's already easy to fill select elements with database data out of the box:

$db = Zend_Db_Table_Abstract::getDefaultAdapter();
$options = $db->fetchPairs(
   $db->select()->from('table_name', array('id', 'display_field'))
     ->order('some_field ASC'), 'id');
$form->getElement('someelement')->AddMultiOptions($options);

In the snippet above you get default database adapter, then simply fetch all items from 'table_name' ordering by 'some_field', and you see we fetch them as pairs binding to 'id' field. This basically means that the result of fetchPairs returns associative array of items. For select control options, we just want two fields: one for the display and one for the values ('id' is the value field, 'display_field' is for display)

But what if you have many database aware select controls? How is it possible to extend Zend Framework select elements with an easy method to populate data from database table?

Read on for details.

Last Updated ( Sunday, 03 October 2010 )