Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MINOR Use better syntax for querying DataList in 3.0 upgrading guide

  • Loading branch information...
commit ed1373d22bb1a0ef618b6c5379fb74b0c931fb93 1 parent f3467a3
@halkyon halkyon authored
Showing with 8 additions and 8 deletions.
  1. +8 −8 docs/en/changelogs/3.0.0.md
View
16 docs/en/changelogs/3.0.0.md
@@ -120,7 +120,7 @@ expressive notation (instead of unnamed arguments).
// before
DataObject::get('Member', '"FirstName" = \'Sam'\', '"Surname" ASC");
// after
- DataList::create('Member')->filter(array('FirstName' => 'Sam'))->sort('Surname');
+ Member::get()->filter(array('FirstName' => 'Sam'))->sort('Surname');
The underlying record retrieval and management is rewritten from scratch, and features
lazy loading which fetches only the records it needs, as late as possible.
@@ -135,13 +135,13 @@ now return a `DataList`.
// before
DataObject::get_one('Member', '"Email" = \'someone@example.com\'');
// after
- DataList::create('Member')->filter('Email', 'someone@example.com')->First();
+ Member::get()->filter('Email', 'someone@example.com')->First();
:::php
// before
DataObject::get_by_id('Member', 5);
// after
- DataList::create('Member')->byID(5);
+ Member::get()->byID(5);
Note that they will return a `DataList` even if they're empty, so if you want to check
for the presence of records, please call the count() method on the `DataList`:
@@ -160,7 +160,7 @@ In the 2.4 ORM it was sometimes necessary to bypass the ORM for performance reas
this command would have been intolerably slow:
:::php
- DataList::create('SiteTree')->count();
+ SiteTree::get()->count();
The 3.0 ORM is more intelligent gives you tools you need to create high-performance code without
bypassing the ORM:
@@ -169,7 +169,7 @@ bypassing the ORM:
// before
echo DB::query("SELECT COUNT(*) FROM \"SiteTree\"")->value();
// after
- echo DataList::create('SiteTree')->count()
+ echo SiteTree::get()->count()
Both `extendedSQL()` and `buildSQL()` have been deprecated. There is not currently any way of
overriding the query generation code equivalent to overriding `buildSQL()` in 2.4, but this facility
@@ -180,7 +180,7 @@ on any DataList. Note that modifications to this query will **not** be passed b
// before
$query = singleton('SiteTree')->extendedSQL('ParentID = 5');
// after
- $query = DataList::create('SiteTree')->filter('ParentID', 5)->dataQuery()->query();
+ $query = SiteTree::get()->filter('ParentID', 5)->dataQuery()->query();
We advise that you keep this kind of code to a minimum and that you use the DataList wherever possible.
If you find yourself needing to bypass the ORM in SilverStripe 3, we suggest you raise this
@@ -296,7 +296,7 @@ Upgrade example: Record listing
$field = new TableListField('Companies', 'Company');
$field->setPageSize(20);
// after
- $field = new GridField('Companies', null, DataList::create('Company'));
+ $field = new GridField('Companies', null, Company::get());
$field->getConfig()->getComponentByType('GridFieldPaginator')->setItemsPerPage(20);
Upgrade example: Record listing with view/edit interface
@@ -305,7 +305,7 @@ Upgrade example: Record listing with view/edit interface
// before
$field = new ComplexTableField($myController, 'Companies', 'Company');
// after
- $field = new GridField('Companies', null, DataList::create('Company'), GridFieldConfig_RecordEditor::create());
+ $field = new GridField('Companies', null, Company::get(), GridFieldConfig_RecordEditor::create());
Upgrade example: Relationship editing

0 comments on commit ed1373d

Please sign in to comment.
Something went wrong with that request. Please try again.