Welcome Guest, Not a member yet? Register   Sign In
where clause with order_by in codeigniter giving me issue
#1

Hi All,

I am new in codeigniter framework, I have to add order_by in my query..
PHP Code:
$data['work']=$this->work->where('wuFk'session()->get('uId'))->get()->getResult(); 



I want to add the order_by('uName','DESC'), added like below but giving me issue, bad method execptions.
PHP Code:
$data['work']=$this->work->where('wuFk'session()->get('uId'))->order_by('uName','DESC')->get()->getResult();

Do 
you have any suggestion for order_by with where clause in query




  $data['work']=$this->work->where('wuFk', session()->get('uId'))->get()->getResult();
Reply
#2

Showing the exact error message would make you get better support.
Reply
#3

Assuming you are using CI4 and a model, issue may be here ->getResult() you should either use getResultArray() if you expect an array or getResultObject() if you expect an object
Web developer creating tools for streamers
Countdown Tools: https://obscountdown.com
Reply
#4

(This post was last modified: 04-01-2024, 11:07 PM by InsiteFX. Edit Reason: Spelling Error )

It's orderBy not order_by if your using CodeIgniter 4.x.x
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#5

(03-27-2024, 12:11 AM)prem16 Wrote: Hi All,



I want to add the order_by('uName','DESC'), added like below but giving me issue, bad method execptions.
PHP Code:
$data['work']=$this->work->where('wuFk'session()->get('uId'))->order_by('uName','DESC')->get()->getResult(); 

Hey hi, use orderBy() instead of order_by()

$data['work']=$this->work->where('wuFk', session()->get('uId'))->order_by('uName','DESC')->get()->getResult();
Reply




Theme © iAndrew 2016 - Forum software by © MyBB