Recovery of the records translated

How to retrieve translated data from a table ?

Each collector can call the method getI18n or getOneI18n which allows to retrieve translated data with or without conditions.

 function getI18n($primary_key_value = ", $order = ", $search = ", $id_loc = ", $id_loc_master = ", $limit = ", $offset = ") { }

Settings

  1. $primary_key_value : can be the value of the primary key OR a table which includes the conditions of recovery.
  2. $order : to sort by order ascending.
  3. $search : to search for a string in the translations.
  4. $id_loc : the language.
  5. $id_loc_master : the language mistress.
  6. $limit : a number that will determine the maximum number of results.
  7. $offset : a number that will determine the starting point of the results.

Example

The following example allows you to retrieve the values of the collector "example" if the field 'is_valid' is equal to 1, in ascending order of the field 'n_order', with 2 results in maximum start with 0.

$conditions = array('is_valid' => 1); 
$rows = $this->collector['example']->getI18n($conditions, 'order by n_order', ", ", '2', '0');

The function's return

This method returns an array containing the values.

Array 
( 
 [0] = Array 
 ( 
 [id_example] = One 
 [lib] = Item 1 
 [created_at] = 2019-05-03 14:33:10 
 [n_order] = One 
 [is_valid] = One 
 [ex_type] = EX1 
 ) 

 [1] = Array 
 ( 
 [id_example] = Three 
 [lib] = Item 3 
 [created_at] = 2019-05-03 14:33:21 
 [n_order] = Three 
 [is_valid] = One 
 [ex_type] = EX2 
 ) 

)

Method getOneI18n

The method getOneI18n works in the same way, the only difference is that the result returns only a single record.

$rows = $this->collector['example']->getOneI18n();