Like keyword can be used with Zend_Db select query
$query = $this->select()
->where("firstname like ?", $letter."%");
try that works.
sharing some useful programming tips with other developers.
Like keyword can be used with Zend_Db select query
$query = $this->select()
->where("firstname like ?", $letter."%");
There is a way to select comma separated data from any mysql table.
SELECT poll_id,group_concat(option_id) FROM `poll_elements`
group by poll_id
If the hidden field added to the Zend form leaves extra space between elements, remove those tags around it.
$this->addElement("hidden", "id",
array('disableLoadDefaultDecorators' => true));
This is the way to select records from tables of different databases
SELECT * FROM `db`.table tb
INNER JOIN `db2`.table2 tb2 ON tb2.id = tb.id
Custom error messages can be added to a form element:
The following shows how to add custom error message to a select element
$countryList = array("0" => "select" ,"1" => "Canada", "2" => "India", "3" => "America");
$countries = new Zend_Form_Element_Select('country');
$countries->setLabel("Country")
->setRequired(true)
->addFilter('Int')
->addMultiOptions($countryList)
->addValidator('GreaterThan',false, array("min"=>1, "messages" => array("notGreaterThan"=>"country is required")));
Merge two arrays together using array_merge function
$result = array_merge(array(0=>"Hello"), array(3=>"World"));
$result = $arr1 + $arr2;
A text element of a form can be made read only therefore user cannot touch the value
$this->addElement('text','current_date',array(
'attribs' => array('readonly' => 'true')));
If you happened to select records in key value pair, try this way
$query = $this->select()
->from($this->_name, array('id', 'name'));
$this->getAdapter()->fetchPairs($query);
If any chance to do an UPDATE on the same table, here is the SQL for that
UPDATE my_list AS a
INNER JOIN my_list AS b
ON a.id = b.id
SET a.list_name_val = md5( b.list_name )
Copyright 2008 Splashpress Media | Converted by eBlog Templates | Blogging Pro Blogger | Designed by Design Disease