Welcome Guest, Not a member yet? Register   Sign In
Need help about Query Bilder
#5

(This post was last modified: 08-30-2019, 08:38 AM by InsiteFX.)

Something like below:

PHP Code:
// Your Model
private $builder;

public function 
__construct()
{
    parent::__construct();

    $db db_connect();
    $this->builder $db->table($table);
}

// get_rows
public function getRows($table$arr)
{
    $this->builder
         
->where($arr)
         ->get()
         ->getResultArray();

    return $this;
}

// order_row
public function orderRow($by)
{
    $this->builder
         
->orderBy($by'desc')
         ->get()
         ->getResultArray();

    return $this;
}

// call using:
$data $this->my_model->orderRow('column')->getRows('my_table', array()) 

Not tested but should work for you.

The table name is in the builder when connecting to the db.

PHP Code:
$this->builder $db->table($table); 
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Messages In This Thread
Need help about Query Bilder - by webdevron - 08-28-2019, 11:55 AM
RE: Need help about Query Bilder - by InsiteFX - 08-28-2019, 04:53 PM
RE: Need help about Query Bilder - by webdevron - 08-29-2019, 04:09 PM
RE: Need help about Query Bilder - by InsiteFX - 08-30-2019, 04:37 AM
RE: Need help about Query Bilder - by webdevron - 08-31-2019, 11:29 AM
RE: Need help about Query Bilder - by InsiteFX - 08-30-2019, 08:36 AM
RE: Need help about Query Bilder - by InsiteFX - 08-31-2019, 12:17 PM
RE: Need help about Query Bilder - by dave friend - 08-31-2019, 02:10 PM
RE: Need help about Query Bilder - by webdevron - 09-01-2019, 04:46 AM
RE: Need help about Query Bilder - by InsiteFX - 09-01-2019, 12:07 PM



Theme © iAndrew 2016 - Forum software by © MyBB