Hello Masters, I am new in Codeignitor but i enjoy here.I have one problem like,
I want only display value comparison last date less then or equal current date. Last date <= current date.here last date mention by user.If last date greater then current date then those value auto delete or desible from table list.

i am trying like this:
Model:

public function selectClsTrainingByUserId($limit,$offset = 0) {
        $this->db->select('*');
        $this->db->where("crs_last_date <=", $date);    // here, crs_last_date mention by user posing time
        $this->db->order_by("upcom_id", "desc");        // and $limit, $offset use for pagination
        $query_result = $this->db->get('tbl_upcoming_course',$limit,$offset);
        $result = $query_result->result();
        return $result;
    }

Please master if you can explain me step by step.

Best Regards,
RJony

You can use the query() method to run one single request:

$sql = "DELETE FROM tbl_upcoming_course as tbl, (SELECT id FROM tbl_upcoming_course WHERE crs_last_date <= ? ORDER BY upcom_id LIMIT ?, ?) as sub WHERE id = sub.id";

$this->db->query($sql, array($date, $limit, $offset));

Before doing this be sure $date is in the correct format. This method returns TRUE/FALSE: http://ellislab.com/codeigniter/user-guide/database/queries.html

Hi,

I am not a master nor closer to a master's bigfoot. However, did you try looking and searching for MySQL date arithmetic function? Once you find out what functions are available for your needs e.g. DATEDIFF, all you need is modify your initial query... that's all..

Hi Cereal,
Your query right if i delete data from list but i just desible value on my frontend show list.hope you understand.

THanks

Then change it to an update query, this with appropriate adjustments should work:

UPDATE tbl_upcoming_course, (SELECT id FROM tbl_upcoming_course WHERE crs_last_date <= ? ORDER BY upcom_id LIMIT ?, ?) as sub SET `column_to_update` = 'value' WHERE id = sub.id;