CakePHP Cookbook Documentation 5.ximproved application performance. See the Improve Your Application’s Performance for how to do this. Collection • Added unique() which filters out duplicate value specified by provided callback. • reject() CakePHP’s models are composed of Table and Entity objects. Table objects provide access to the collection of entities stored in a specific table. They are stored in src/Model/Table. The file we’ll be creating add this use statement right below the namespace declaration to import // the Collection class use Cake\Collection\Collection; // Update the accessible property to contain `tag_string` protected array $_accessible0 码力 | 848 页 | 2.53 MB | 1 年前3
CakePHP Cookbook Documentation 5.xCollections Collection Quick Example List of Methods Iterating Collection::each() Collection::map() Collection::extract() Collection::combine() Collection::stopWhen() Collection::unfold() Collection::chunk() Collection::chunk() Collection::chunkWithKeys() Filtering Collection::filter() Collection::reject() Collection::every() Collection::some() Collection::match() Collection::firstMatch() Aggregation Collection::reduce() Collection::reduce() Collection::min() Collection::max() Collection::sumOf() Collection::avg() Collection::median() Grouping and Counting Sorting Collection::sortBy() Working with Tree Data Collection::nest() Coll0 码力 | 1080 页 | 939.39 KB | 1 年前3
CakePHP Cookbook 3.x
CakePHP’s models are composed of Table and Entity objects. Table objects provide access to the collection of entities stored in a specific table. They are stored in src/Model/Table. The file we’ll be creating Features Collection • CollectionTrait now uses the newCollection method to create clones. This allows sub-classes to have collection methods create instances of themselves instead of using Collection. 3.8 Cache • Fallback engines can be disabled by setting fallback = false for any cache configuration. Collection • The appendItem(), prepend(), prependItems() methods were added to CollectionTrait. 3.6 Migration0 码力 | 967 页 | 2.80 MB | 1 年前3
CakePHP Cookbook 4.x
CakePHP’s models are composed of Table and Entity objects. Table objects provide access to the collection of entities stored in a specific table. They are stored in src/Model/Table. The file we’ll be creating signature of any methods they do change the semantics or behavior of methods. Collection • Collection::groupBy() and Collection::indexBy() now throw an exception when the path does not exist or the path do not change the signature of any methods they do change the semantics or behavior of methods. Collection • Renamed $preserveKeys parameter to $keepKeys with same implementation. Command • cake i18n0 码力 | 967 页 | 2.88 MB | 1 年前3
CakePHP Cookbook 4.x
Collections Collection Quick Example List of Methods Iterating Collection::each() Collection::map() Collection::extract() Collection::combine() Collection::stopWhen() Collection::unfold() Collection::chunk() Collection::chunk() Collection::chunkWithKeys() Filtering Collection::filter() Collection::reject() Collection::every() Collection::some() Collection::match() Collection::firstMatch() Aggregation Collection::reduce() Collection::reduce() Collection::min() Collection::max() Collection::sumOf() Collection::avg() Collection::median() Grouping and Counting Sorting Collection::sortBy() Working with Tree Data Collection::nest() Coll0 码力 | 1249 页 | 1.04 MB | 1 年前3
CakePHP Cookbook 3.x
Tree Data Other Methods Withdrawing Elements Expanding Collections Modifiying Elements Making Collection Methods Reusable Optimizing Collections Making Collections Rewindable Cloning Collections Folder CakePHP’s models are composed of Table and Entity objects. Table objects provide access to the collection of entities stored in a specific table. They are stored in src/Model/Table. The file we’ll be creating Features Collection CollectionTrait now uses the newCollection method to create clones. This allows sub-classes to have collection methods create instances of themselves instead of using Collection. Console0 码力 | 1244 页 | 1.05 MB | 1 年前3
Laravel 5.6 中文文档return view('user.index', ['users' => $users]); } } get 方法返回包含结果集的 Illuminate\Support\Collection,其中每一个结果都是 PHP 的 StdClass 对象实例: 你可以像访问对象的属性一样访问字段的值: foreach ($users as $user) { echo 查询中使用查询构建器的所有方法。 集合 对 Eloquent 中获取多个结果的方法(比如 all 和 get)而言,其返回值是 Illuminate\Database\Eloquent\Collection 的一个实例, Collection 类提供了多个有用的函数来处理 Eloquent 结果集: $flights = $flights->reject(function ($flight) { return 中文学习资源:http://laravelacademy.org 176 Eloquent 返回的包含多条记录的结果集都是 Illuminate\Database\Eloquent\Collection 对象的实例,包括通过 get 方法或者通过访问关联关系 获取的结果。Eloquent 集合对象继承自 Laravel 的集合基类,因此很自然的继承了很多处理 Eloquent 模型底层数组的方法。0 码力 | 377 页 | 14.56 MB | 1 年前3
Laravel 5.1 中文文档$columns); // ... return $model; } lists 方法 lists 方法现在返回一个 Collection 实例而不是包含 Eloquent 查询结果的数组,如果你想 将 Collection 转化为数组,使用 all 方法: User::lists('id')->all(); 注意:Query Builder 的 lists 返回的仍然是数组。 6 Collection 类 sortBy 方法 sortBy 方法现在返回一个新的 collection 实例而不是改变已有的 collection: $collection = $collection->sortBy('name'); groupBy 方法 groupBy 方法现在为每个父级 Collection 中的 item 返回 Collection 实例,如果你想要将这些 map 方法实现: $collection->groupBy('type')->map(function($item){ return $item->all(); }); lists 方法 lists 方法现在返回一个 Collection 实例而不是数组,如果你想要将 Collection 转化数组,使 用 all 方法: $collection->lists('id')->all();0 码力 | 307 页 | 3.46 MB | 1 年前3
Laravel 6.0 中文文档RateLimited]; } 懒集合 许多开发者已经使用过 Laravel 功能强大的集合方法了,在 Laravel 6.0 中新引入了一个 LazyCollection 类来对 Collection 类进行 补充,LazyCollection 底层基于 PHP 的生成器实现,适用于处理 大型数据集。 例如,假设你的应用需要处理 GB 级别的日志文件,并使用 Laravel 的集 un.com 607 集合 简介 Illuminate\Support\Collection 类为处理数组数据提供了流式、 方便的封装。例如,查看下面的代码,我们使用辅助函数 collect 创 建一个新的集合实例,为每一个元素运行 strtoupper 函数,然后移 除所有空元素: $collection = collect(['taylor', 'abigail', null])->m 正如你所看到的,Collection 类允许你使用方法链对底层数组执行 匹配和移除操作,通常,每个 Collection 方法都会返回一个新 的 Collection 实例。 创建集合 正如上面所提到的,辅助函数 collect 为给定数组返回一个新 的 Illuminate\Support\Collection 实例,所以,创建集合很简单: $collection = collect([10 码力 | 1442 页 | 14.66 MB | 1 年前3
Laravel 5.2 中文文档建器的所有方法。 集合 对 Eloquent 中获取多个结果的方法(比如 all 和 get)而言,其返回值是 Illuminate\Database\Eloquent\Collection 的一个实例,Collection 类提供了多个有用 的函数来处理 Eloquent 结果。当然,你可以像操作数组一样简单循环这个集合: foreach ($flights as $flight) { comment!'; $comment->save(); 集合 1、简介 Eloquent 返回的所有的包含多条记录的结果集都 是 Illuminate\Database\Eloquent\Collection 对象的实例,包括通过 get 方法或者通过访 问关联关系获取的结果。Eloquent 集合对象继承自 Laravel 的集合基类,因此很自然的继 承了很多处理 Eloquent 模型底层数组的方法。 Eloquent 集合实例 * * @param array $models * @return \Illuminate\Database\Eloquent\Collection */ public function newCollection(array $models = []) { return new Cus0 码力 | 377 页 | 4.56 MB | 1 年前3
共 62 条
- 1
- 2
- 3
- 4
- 5
- 6
- 7













