Thank you, that is what i want to know.
Code:
$var1 = \XF::finder('XF:xf_purchase_request')
->where('provider_metadataIndex', $state->subscriberId)
->where('cost_amount',$state->cost)
->fetchOne();
Very often or maybe always(?) i see something like this, but without selecting a field.
It doesnt matter if i selecting millions of times in a day
SELECT * instead of SELECT field1, field2 ?
What is the syntax to fetch only fields, please?
$var1 = \XF::finder('XF:xf_purchase_request')->request_key->where ...
OR
$var1 = \XF::finder('XF:xf_purchase_request')->where ...
->fetchOne()->request_key;
And this one:
fetch()->toArray();
i can use?
One of the main differences between the direct query approach and using the Finder is that the base unit of data returned by the Finder is not an array. In the case of a Finder object which calls the fetchOne method (which only returns a single row from the database), a single Entity object will be returned.
I still dont see the need for an object instead of an array for my small needs (maybe because i still dont understand the difference) and maybe because i dont need protection and things like that.)
I have only small problems to solve like
if node.depth == 2, $x=parent_node_id, else $x=node_id
$y=siblings($x); $z=children($x);
and many times i just just no idea what is happen and not happen here with these objects, while an array is something nice and handy for me.