Welcome Guest, Not a member yet? Register   Sign In
ar_orderby has changed to qb_orderby
#1

When checking to see if a db->order_by has been set

If ( ! count( $this->db->ar_orderby ) ) { /* */ }

php notice message Undefined property: CI_DB_mysqli_driver::$ar_orderby

Looking through I see it has been changed to qb_orderby

when running

If ( ! count( $this->db->qb_orderby ) ) { /* */ }

we get error message

Fatal error: Cannot access protected property CI_DB_mysqli_driver::$qb_orderby

Any clues how we can add a conditional statement to see if an order_by has been set ??
Most things broken in our house was done by nobody, the rest was my fault anyway Huh
Reply
#2

when was an ar_orderby in the past? Don't remember seeing it in the documentation...
Reply
#3

You basically have three options:
- track it yourself,
- use get_compiled_select() and check the result for an order by statement, or
- modify your database driver to give you a method to check qb_orderby.
Reply
#4

It never was in the documentation, just one of those hidden gems that you got to learn about. Basically it allows you to see if $this->db->orderby() has been set prior to running the query if not then you could set one.

When running print_r prior to running the query on $this->db I can see that ar_orderby has been changed to qb_orderby

How can we now run a check prior to running the db->get to see if db->orderby has been set ?

Many thanks
Most things broken in our house was done by nobody, the rest was my fault anyway Huh
Reply
#5

(02-08-2015, 01:18 PM)dollardad Wrote: It never was in the documentation, just one of those hidden gems that you got to learn about.  Basically it allows you to see if  $this->db->orderby() has been set prior to running the query if not then you could set one.

When running print_r prior to running the query on $this->db I can see that ar_orderby has been changed to qb_orderby

How can we now run a check prior to running the db->get to see if db->orderby has been set ?

Many thanks

You can't and you shouldn't.
This is not a gem that you happen to learn about, it hasn't been undocumented for no reason - it's an internal property that you should've never relied on.
Reply
#6

@Narf

Thanks for the heads-up on this one and I've changed my code as per. However, methinks you might get a few queries on this one when people move to CI 3 as this "not so little gem" was one of the tricks published on "Codeigniter learning series" by Nettuts.
Most things broken in our house was done by nobody, the rest was my fault anyway Huh
Reply
#7

Well, it's really bad if a a tutorials site has suggested using such hacks ... but still, the closest thing that I could suggest as a work-around is Reflection. And even that, I'd discourage.
Reply
#8

Good discussion guys I would thank you, becuase I'm just watching this course by tutsplus and I found this code seems very weird to me. But anyway Joost van veen is one of my favorite lecturers I enjoy learning from him.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB