Welcome Guest, Not a member yet? Register   Sign In
Model query with paging does not work
#1

When I use pagination and in the query there is an 'orderBy()',  codeigniter returns an error: Duplicate column name 'created_at'.
Does anyone know how to resolve this situation?
My code:

Code:
$transacao = $this->transacao_model        
->select('*')
->where('event.id', 32)
->join('...')
...
->orderBy('event.id');

$data = [
  'transacao' => $transacao->paginate(30, ''),
  'pager' => $transacao->pager
];


Ps.
Sorry for my english.
Reply
#2

(This post was last modified: 09-16-2021, 05:55 PM by wdeda.)

My apologies, for greater understanding I will use our native language, mine and #thiaxi's, Portuguese.

Vamos lá. Acredito que as coisas estão invertidas, para não complicar muito, abaixo, um controller meu, bem similar ao seu. Penso que lhe dará, espero, a montagem correta:
PHP Code:
$model = new AlbumModel();      

        $style 
$model->getGenre1($id);        

        $data 
= [
            'genre1' => $model->orderBy('player_id''ano''title''asc')
            ->where('style1'$style)
            ->paginate(20), 
            'pager' => $model->pager,
            'total' => $model->numGenre1($id),
            'genre' => $model->getGenre1($id),
            'linkx' => $model->getLinkx($id)                        
        
]; 
Reply
#3

(09-16-2021, 05:50 PM)wdeda Wrote: My apologies, for greater understanding I will use our native language, mine and #thiaxi's, Portuguese.

Vamos lá. Acredito que as coisas estão invertidas, para não complicar muito, abaixo, um controller meu, bem similar ao seu. Penso que lhe dará, espero, a montagem correta:
PHP Code:
$model = new AlbumModel();      

        $style 
$model->getGenre1($id);        

        $data 
= [
            'genre1' => $model->orderBy('player_id''ano''title''asc')
            ->where('style1'$style)
            ->paginate(20), 
            'pager' => $model->pager,
            'total' => $model->numGenre1($id),
            'genre' => $model->getGenre1($id),
            'linkx' => $model->getLinkx($id)                        
        
]; 

Good Morning. Thanks for the answer. I tried to use your answer to fix the error but it didn't work.

Paging does not work with GroupBy.
If I remove GroupBy, the code works.

I'm uploading some images of the error.

[Image: 0asQzGQ.jpg]

[Image: yTXTO98.jpg]
Reply




Theme © iAndrew 2016 - Forum software by © MyBB