PHP latest date

How would you write a query if you were trying to find the last entry / the latest entry?

$order_query = $this->EE->db->select('*')
					->where('member_id', $member)
					->where('status', 'open')
                                     [b]   ->where('id', 'WHERE ID IS THE HIGHEST NUMBER')[/b]
					->get('exp_cartthrob_subscriptions');

Open in new window

LVL 8
rgranlundAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dave BaldwinFixer of ProblemsCommented:
Your 'where' can't work.  Do
ORDER BY `id` DESC LIMIT 1

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rgranlundAuthor Commented:
When I do it that way, I get this error:
Fatal error: Call to undefined method CI_DB_mysql_driver::orderby()
<?php
		$order_query = $this->EE->db->select('*')
					->where('member_id', $member)
					->where('status', 'open')
					->orderby('order_id', 'desc')
					->get('exp_cartthrob_subscriptions');

Open in new window

0
Dave BaldwinFixer of ProblemsCommented:
'ORDER BY' is standard SQL.  I have no idea what 'CI_DB_mysql_driver' is.  But if it doesn't support 'ORDER BY' then it is wrong.  Simply wrong.  Do some research, that can't be right.  Maybe there is a different way of doing it.
0
C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Dave BaldwinFixer of ProblemsCommented:
What worked?
0
rgranlundAuthor Commented:
Once you mention order by, I needed to look it up and it is ->order_by
0
Dave BaldwinFixer of ProblemsCommented:
Oh, thanks, good to know.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.