SetUsedFields / RollBackUsedFields

Define the fields used by data recovery methods

Change the fields that are used by the SQL query

It is possible to define what will be the fields used by the methods of the Genclass.

By default, the fields used are those of the collector, without exception.
Thus, the following piece of code will retrieve all the rows in the table "gen_example" with all of the available fields :

$rows = $this->collector['example']->get(); // The query that is generated will then be : 
SELECT id_example, lib, created_at, n_order, is_valid, ex_type FROM gen_example

If, for reasons of performance or simply for convenience, one wishes to select only some fields, it is possible to do so via the method SetUsedFields.

$this->collector['example']->SetUsedFields(array('id_example', 'lib'));<br /><br />

In this case, we will have :

$rows = $this->collector['example']->get(); // The query that is generated will then be : 
SELECT id_example, lib FROM gen_example

Return to the initial state

Thanks to the method RollBackUsedFields it is possible to return to the initial operation to select all the columns from the table used.

$this->collector['example']->RollBackUsedFields();