Skip to content
This repository
Browse code

MINOR Use better syntax for querying DataList in 3.0 upgrading guide

  • Loading branch information...
commit ed1373d22bb1a0ef618b6c5379fb74b0c931fb93 1 parent f3467a3
Sean Harvey authored May 28, 2012

Showing 1 changed file with 8 additions and 8 deletions. Show diff stats Hide diff stats

  1. 16  docs/en/changelogs/3.0.0.md
16  docs/en/changelogs/3.0.0.md
Source Rendered
@@ -120,7 +120,7 @@ expressive notation (instead of unnamed arguments).
120 120
 	// before
121 121
 	DataObject::get('Member', '"FirstName" = \'Sam'\', '"Surname" ASC");
122 122
 	// after
123  
-	DataList::create('Member')->filter(array('FirstName' => 'Sam'))->sort('Surname');
  123
+	Member::get()->filter(array('FirstName' => 'Sam'))->sort('Surname');
124 124
 	
125 125
 The underlying record retrieval and management is rewritten from scratch, and features
126 126
 lazy loading which fetches only the records it needs, as late as possible.
@@ -135,13 +135,13 @@ now return a `DataList`.
135 135
 	// before
136 136
 	DataObject::get_one('Member', '"Email" = \'someone@example.com\'');
137 137
 	// after
138  
-	DataList::create('Member')->filter('Email', 'someone@example.com')->First();
  138
+	Member::get()->filter('Email', 'someone@example.com')->First();
139 139
 
140 140
 	:::php
141 141
 	// before
142 142
 	DataObject::get_by_id('Member', 5);
143 143
 	// after
144  
-	DataList::create('Member')->byID(5);
  144
+	Member::get()->byID(5);
145 145
 
146 146
 Note that they will return a `DataList` even if they're empty, so if you want to check 
147 147
 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
160 160
 this command would have been intolerably slow:
161 161
 
162 162
 	:::php
163  
-	DataList::create('SiteTree')->count();
  163
+	SiteTree::get()->count();
164 164
 	
165 165
 The 3.0 ORM is more intelligent gives you tools you need to create high-performance code without
166 166
 bypassing the ORM:
@@ -169,7 +169,7 @@ bypassing the ORM:
169 169
 	// before
170 170
 	echo DB::query("SELECT COUNT(*) FROM \"SiteTree\"")->value();
171 171
 	// after
172  
-	echo DataList::create('SiteTree')->count()
  172
+	echo SiteTree::get()->count()
173 173
 
174 174
 Both `extendedSQL()` and `buildSQL()` have been deprecated.  There is not currently any way of 
175 175
 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
180 180
 	// before
181 181
 	$query = singleton('SiteTree')->extendedSQL('ParentID = 5');
182 182
 	// after
183  
-	$query = DataList::create('SiteTree')->filter('ParentID', 5)->dataQuery()->query();
  183
+	$query = SiteTree::get()->filter('ParentID', 5)->dataQuery()->query();
184 184
 
185 185
 We advise that you keep this kind of code to a minimum and that you use the DataList wherever possible.
186 186
 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
296 296
 	$field = new TableListField('Companies', 'Company');
297 297
 	$field->setPageSize(20);
298 298
 	// after
299  
-	$field = new GridField('Companies', null, DataList::create('Company'));
  299
+	$field = new GridField('Companies', null, Company::get());
300 300
 	$field->getConfig()->getComponentByType('GridFieldPaginator')->setItemsPerPage(20);
301 301
 
302 302
 Upgrade example: Record listing with view/edit interface
@@ -305,7 +305,7 @@ Upgrade example: Record listing with view/edit interface
305 305
 	// before
306 306
 	$field = new ComplexTableField($myController, 'Companies', 'Company');
307 307
 	// after
308  
-	$field = new GridField('Companies', null, DataList::create('Company'), GridFieldConfig_RecordEditor::create());
  308
+	$field = new GridField('Companies', null, Company::get(), GridFieldConfig_RecordEditor::create());
309 309
 
310 310
 
311 311
 Upgrade example: Relationship editing

0 notes on commit ed1373d

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