How from the usual array to translate in Resultset?


The task is to take the data from the database, rework them and give them to the view. How to do it?

$sql = "SELECT * FROM table "; 

 $query = $this->db->query(sql) ; 

$items = $query->fetchAll();

$new_items = array();

foreach($items as $i) {


$i["values"] = "new val";


$new_items[] = $i;


$new_result = ???????? ($new_items);

$result = new Resultset(null, new Models, $new_result);

$paginator = new Paginator([
                        "data" => $result,
                        "limit" => 10,
                        "page" => 1
edited 13d ago

I dont understand your problem, just send it to the view like described in the doc, depending of how you want to use them :

Controller :
// with example of ['a'=>1, 'b'=>2, 'c'=>3];
// 1. to access to each data as variable by his name
// 2. to access to the result object
$this->view->result = $result; 
// 3. to access to the result array
$this->view->result = $result->toArray();

View :
// output 123
// 1.
echo $a.$b.$c; 
// 2.
echo $result->a.$result->b.$result->c;
// 3
echo $result['a'].$result->['b'].$result['c'];

It doesn't sound like English is your first language, but please try to explain your situation more. What is the expected outcome? What outcome are you actually experiencing?

Sorry for my english.

I make a request to the database. The value in the value column must be calculated and replaced. Then give the result to Paginator. In the code, an incomprehensible place is marked with signs ?????????