db->tblMember} as Member WHERE email = ".$this->db->quote($email); $data = $this->db->queryRow($sql); return $data; } function getUniqueAccessCode() { do { list($usec, $sec) = explode(" ",microtime()); $access_code = md5(time().rand(1, 300).(((float)$usec + (float)$sec))); } while (!$this->isUniqueAccessCode($access_code)); return $access_code; } function isUniqueAccessCode($access_code) { $sql = "SELECT COUNT(*) FROM {$this->tableNameDB} WHERE access_code = ".$this->db->quote($access_code, 'text'); return !(bool)$this->db->queryOne($sql); } function getFromDBByAccessCode($access_code) { $sql = "SELECT * FROM {$this->tableNameDB} WHERE access_code = ".$this->db->quote($access_code, 'text'); $res = $this->db->queryRow($sql); $this->_sqlError($res); return $res; } function isUniqueMemberEmail($name) { $sql = "SELECT COUNT(*) FROM {$this->db->tblMember} WHERE email = ".$this->db->quote($name); if ($this->id){ //$sql .= ' AND id != '.$this->db->quote($this->id); } return !(bool)$this->db->queryOne($sql) ; } function register() { $data = $this->getData(); require_once('class/DB/DBTable.php'); $table = new DBTable('Member'); $data['is_support_account'] = 'y'; $data['id_misc_type'] = 3; $data['id_misc_status'] = 1; $data['email_verified'] = 'y'; $data['info_verified'] = 'y'; $id = $table->insert($data); return $id; } function assignMember($id_support_account, $id_member) { require_once('class/DB/DBTable.php'); $table = new DBTable('Member2Member'); $sql = " SELECT COUNT(*) FROM {$this->db->tblMember2Member} WHERE id_parent = ".intval($id_support_account)." AND id_member = ".intval($id_member)." "; if (!(int)$this->db->queryOne($sql)) { $data = array( 'id_parent' => $id_support_account, 'id_member' => $id_member, ); $table->insert($data); } return true; } }