php - Delete Query from codeigniter -


i'm trying figure out how need query. i'm trying delete users have registered not activated witin time limit.

function purgena($expireperiod) {     $this->db->where('usersstatusesid', 1);     $this->db->where('unix_timestamp(registrationdate) <', time() - $expireperiod);     $this->db->delete($this->usersregistrationstable); } 

here's db structure:

usersregistrationstable - userid, registrationdate userstable              - userid, usersstatusesid 

to knowledge, codeigniter doesn't support joins in delete queries via active record interface. instead, you'll need execute sql statement:

$sql = "delete            userstable u           join usersregistrationstable r on u.userid = r.userid           usersstatusesid = 1 , unix_timestamp(registrationdate) < ?"; $this->db->query($sql, array(time() = $expireperiod)); 

Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -