Welcome Guest, Not a member yet? Register   Sign In
order_by() how to use NULLS LAST in active records
#3

(This post was last modified: 11-05-2020, 04:26 AM by brianjamestorr.)

(11-05-2020, 03:54 AM)vincent78 Wrote: Try:
$this->db->order_by('b.following', 'desc nulls last');

with the modification:
in the file ./system/database/DB_query_builder.php -> public function order_by($orderby, $direction = '', $escape = NULL)
there is a line:
$direction = in_array($direction, array('ASC', 'DESC'), TRUE) ? ' '.$direction : '';
-> modify it:
$direction = in_array($direction, array('ASC', 'DESC', 'ASC NULLS LAST', 'DESC NULLS LAST'), TRUE) ? ' '.$direction : '';

Thanks this works.
Reply


Messages In This Thread
RE: order_by() how to use NULLS LAST in active records - by brianjamestorr - 11-05-2020, 04:04 AM



Theme © iAndrew 2016 - Forum software by © MyBB