[eluser]tolinho[/eluser]
I have been a happy user of this little code for some time now:
Code:
// what if order by has been set outsite this model?
// so we check to see if order_by has been set creating a condition for: $this->db->ar_orderby
if (!count($this->db->ar_orderby))
{
// so if its empty its safe to set order by
$this->db->order_by($this->_order_by);
}
Never had an issue with it until now.
I was using the code above with codeigniter 2.1.4 but today I decided to get my hands dirty and start to upgrade my site to ci 3.
I have been reading a lot and following the how to upgrade page.
There is some information about mysql + deprecated + active record...
Then it hit me. Codeigniter 3 is using Query Builder
Ci 2.1.4 = ar_orderby
Ci 3.0 dev = qb_orderby
I was sure that I had tracked it...
Changed the code to
Code:
// what if order by has been set outsite this model?
// so we check to see if order_by has been set creating a condition for: $this->db->ar_orderby
if (!count($this->db->qb_orderby))
{
// so if its empty its safe to set order by
$this->db->order_by($this->_order_by);
}
but now I get the error:
Fatal error: Cannot access protected property
After digging a little more I see that ci 2.1.4 system\database\DB_active_rec.php has
Code:
class CI_DB_active_record extends CI_DB_driver {
...
var $ar_orderby = array();
and system\database\DB_query_builder.php has
Code:
abstract class CI_DB_query_builder extends CI_DB_driver {
...
/**
* QB ORDER BY data
*
* @var array
*/
protected $qb_orderby = array();
So I guess I have found what causes this error mentioned, but I dont know how to "unprotect qb_orderby" from DB_query_builder.php
Even getting this error, part of my site loads, with itens loaded from database.
So I guess my update is going okay, has i'm able to query the database. Well part of it.
All I need is the fix for if (!count($this->db->qb_orderby))
Any suggestions?
Thanks