Skip to content

Instantly share code, notes, and snippets.

@housni
Created February 14, 2012 16:43
Show Gist options
  • Save housni/1828019 to your computer and use it in GitHub Desktop.
Save housni/1828019 to your computer and use it in GitHub Desktop.
Model:
<?php
class ZipCodes extends \app\extensions\data\Model {
protected $_meta = array(
'key' => 'zip_code_id',
'title' => 'state_name'
);
protected $_schema = array(
'state_name' => array('type' => 'varchar'),
'StateFIPS' => array('type' => 'varchar')
);
}
?>
A method in my controller
<?php
public static function statesDropdown()
{
$zipcodes = Zipcodes::find('list', array(
'fields' => array('DISTINCT StateFIPS, state_name'),
'order' => 'state_name ASC',
'conditions' => array('state_name' => array('!=' => ''))
)
);
//this returns an empty array.
//but, running the logged query via mysql CLI yields the desired results
return compact('zipcodes');
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment