Skip to content

Instantly share code, notes, and snippets.

@stojg
Created February 12, 2011 09:02
Show Gist options
  • Select an option

  • Save stojg/823631 to your computer and use it in GitHub Desktop.

Select an option

Save stojg/823631 to your computer and use it in GitHub Desktop.
An example on how to add indexes on silverstripe dataobjects
<?php
class SiteTreeOptimizationDecorator extends DataObjectDecorator {
public function extraStatics() {
return array(
'indexes' => array(
// Will help when fetching menu's
'showinmenus_sort' => '(ShowInMenus,Sort)',
// Will help when fetching a page from sitetree
'urlsegment_sort' => '(URLSegment,Sort)',
)
);
}
}
<?php
class WidgetOptimizationDecorator extends DataObjectDecorator {
public function extraStatics() {
return array(
'indexes' => array(
// Will help when fetching widget
'parentid_sort' => '(ParentID,Sort)',
)
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment