Reputation: 117
This is my table:
id t_id min max range name
1 2 2 6 2 Peter
2 2 3 5 3 Leofer
3 2 3 5 4 Josh
4 2 3 5 5 Sonny
5 2 2 6 6 Sammy
I want to delete the records for Peter
and Sammy
. Everything in this table consists of variable data, so using the column names would be the best solution.
Here is my code so far:
for ($x = 0; $x <= sizeof($pick); $x++ )
{
$where = ('pick_range' < $pick[$x] && 'pick_range' > $pick[$x] );
$this->db->select('*');
$this->db->where('teaser_id',$first_page_data['teaser_id']);
$this->db->where('sb_id',$sbid);
$this->db->where('pick_range ', $where);
$query = $this->db->get('tbl_name');
if($query->num_rows() == 1);
{
$this->db->where('pick_range',$where);
$this->db->where('teaser_id',$first_page_data['teaser_id']);
$query = $this->db->delete('tbl_name');
}
}
Is there any other simple approach to do this?
Upvotes: 0
Views: 67
Reputation: 9044
You can try this:
for ($x = 0; $x <= sizeof($pick); $x++ )
{
$this->db->trans_start();
$where = ('pick_range' < $pick[$x] && 'pick_range' > $pick[$x] );
//$this->db->select('*');
$this->db->where('teaser_id',$first_page_data['teaser_id']);
$this->db->where('sb_id',$sbid);
$this->db->where('pick_range ', $where);
//$query = $this->db->get('tbl_name');
//if($query->num_rows() == 1);
//{
$this->db->where('pick_range',$where);
$this->db->where('teaser_id',$first_page_data['teaser_id']);
$this->db->delete('tbl_name');
$this->db->trans_complete();
return TRUE;
//}
}
This will delete data that matches the WHERE
clause.
Upvotes: 1