Skip to content

Instantly share code, notes, and snippets.

@joshtronic
Created October 3, 2010 18:57
Show Gist options
  • Save joshtronic/608815 to your computer and use it in GitHub Desktop.
Save joshtronic/608815 to your computer and use it in GitHub Desktop.
PICKLES Old Model versus New Model
<?php
class search extends Module
{
public function __default()
{
// Pulls all the active cities
$city = new City('list', array('fields' => 'slug, name', 'conditions' => array('active' => '1')));
$cities = array_merge(array(null => 'select your city'), $city->records);
return array('cities' => $cities);
}
}
?>
<?php
class search extends Module
{
public function __default()
{
// Pulls all the active cities and flattens the data
$city = new City(array('active' => '1'));
$cities = array('' => 'select your city');
while ($city->record)
{
$cities[$city->record['slug']] = $city->record['name'];
$city->next();
}
return array('cities' => $cities);
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment