-
Thiaxl
Newbie
-
Posts: 7
Threads: 5
Joined: Sep 2021
Reputation:
0
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.
-
wdeda
Member
-
Posts: 134
Threads: 5
Joined: Dec 2014
Reputation:
1
09-16-2021, 05:50 PM
(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) ];
-
Thiaxl
Newbie
-
Posts: 7
Threads: 5
Joined: Sep 2021
Reputation:
0
(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.
|