what is the difference between collection and array in php (propel)? -
collections , on-demand hydration
advantage of using a collection instead of array propel can hydrate model objects on demand. using feature, you'll never fall short of memory when retrieving large number of results. available through setformatter() method of model queries, on-demand hydration easy trigger:
<?php $authors = authorquery::create() ->limit(50000) ->setformatter(modelcriteria::format_on_demand) ->find(); foreach ($authors $author) { echo $author->getfirstname(); }
1) what meaning of "hydration" here?
2) what difference between collection , array?
source : propel @1.6
1.hidration
a means improve performance "filling" class/object row data when need it.
instead of doing "select * sometable"
large table, propel fire off "select id sometable"
, inside loop, "select [colums] sometable id=[currentid]"
, hence "on demand"
2. collection vs array array normal array, whereas propelcollection object of objects, has lot of stuff available such as:
- paging results
- checking odd or even,
->isodd()
, etc. - checking number of items in
$object->count()
- format converting
->toyaml()
,->tocsv()
,->toxml()
each item in collection propelobject, can still fetch data ->getcolumn()
inside loop. documentation
Comments
Post a Comment