Retrieving records

How to retrieve data from a table ?

Each collector can call the method get or getOne that allows you to retrieve data with or without conditions.

 function get($primary_key_value = ", $order = ", $limit = ", $offset = ", $tables = ", $join = ") { }

Settings

  1. $primary_key_value : can be the value of the primary key OR a table which includes the conditions of recovery.
  2. $order : the name of a field on which to perform a sort by order ascending.
  3. $limit : a number that will determine the maximum number of results.
  4. $offset : a number that will determine the starting point of the results.
  5. $tables : a table with the names of the tables on which one wishes to perform joins.
  6. $join : the joins themselves.

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']->get($conditions, '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 getOne

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

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

Method aget

It is also possible to use the method aget, which has the same function return the get method. These are the settings that are used differently, to know that the settings will be in the form of a single table.

function aget($param) { }<br />

The table is defined as follows :

$mixed = (isset($param['conditions'])) ? $param['conditions'] : ";<br />
$order = (isset($param['order'])) ? $param['order'] : ";<br />
$limit = (isset($param['limit'])) ? $param['limit'] : ";<br />
$offset = (isset($param['offset'])) ? $param['offset'] : ";<br />
$tables = (isset($param['tables'])) ? $param['tables'] : ";<br />
$join = (isset($param['join'])) ? $param['join'] : ";<br />
$search = (isset($param['search'])) ? $param['search'] : ";<br />
$id_loc = (isset($param['id_loc'])) ? $param['id_loc'] : ";<br />
$id_loc_master= (isset($param['id_loc_master'])) ? $param['id_loc_master'] : ";<br /><br />