Paging in Codeigniter with error Type: Error Message: Unsupported operand types

Asked

Viewed 156 times

0

I have a function that takes all the values from the database and sends them to a view, then I’m making a pagination. Only when I put the

 $this->pagination->create_links()

of the variable array he makes a mistake:

Where the mistake is this:

Type: Error

Message: Unsupported operand types

Filename: /var/www/html/idbl/system/libraries/Pagination.php

When I take the

$this->pagination->create_links()

It comes back to work.

I will pass on my full function here:

public function artigo_all() {
    $this->load->library('pagination');
    $config['base_url'] = base_url('site/artigo_all');
    $config['total_rows'] = $this->artigo->GetAll(false, "artigo_id", 'asc');
    $config['per_page'] = 3;
    $qnt = $config['per_page'];
    ($this->uri->segment(3) != "") ? $inicio = $this->uri->segment(3) : $inicio = 0;
    $this->pagination->initialize($config);

    $dados = array(
        'titulo' => 'Todos os artigos',
        'artigo' => $this->artigo->GetAll(false, "artigo_id", 'asc', $qnt, $inicio),
        'jeans' => $this->jeans->GetAll(false, 'jeans_id', 'asc'),
        'aniverMes' => $this->aniver->aniversarianteMes(),
        'aniverDes' => $this->aniver->aniversarianteMes(),
        'paginacao' => $this->pagination->create_links(),
    );

    $this->template->load('front/tema_front', 'front/todos_artigos', $dados);
}

What can it be?

  • Natan has this line that is doing nothing: ($this->uri->segment(3) != "") ? $inicio = $this->uri->segment(3) : $inicio = 0; I thought it would be $inicio = ($this->uri->segment(3) != "") ? $this->uri->segment(3) : 0; has also other problems total_rows is even returning the amount of record? and within the array $dados has two keys which is assigned the same value $this->aniver->aniversarianteMes() Why? There are enough mistakes so give a exception Unsupported operand types

  • I hadn’t even noticed that, now I’ve arranged a lot of thanks.

  • Managed to solve everything?

  • All good. Thank you very much

1 answer

1


Most likely your problem is when you set the variable value: $config['total_rows'] , That is, in your controller, check the method and or return (value) of the method, which is assigning value to variable:

$config['total_rows'] = 200; //integer value

Browser other questions tagged

You are not signed in. Login or sign up in order to post.