Created
February 14, 2012 16:43
-
-
Save housni/1828019 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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