<?php
/***************************************************************************
- * Copyright (C) 2003-2007 Polytechnique.org *
+ * Copyright (C) 2003-2008 Polytechnique.org *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
FROM mentor
WHERE uid = {?}",
S::i('uid'));
- $this->value['expertise'] = $res->fetchOneCell();
+ $this->values['expertise'] = $res->fetchOneCell();
}
protected function _saveData()
{
if ($this->changed['expertise']) {
- XDB::execute("REPLACE INTO mentor (uid, expertise)
- VALUES ({?}, {?})",
- S::i('uid'), $this->values['expertise']);
+ $expertise = trim($this->values['expertise']);
+ if (empty($expertise)) {
+ XDB::execute("DELETE FROM mentor
+ WHERE uid = {?}",
+ S::i('uid'));
+ $this->values['expertise'] = null;
+ } else {
+ XDB::execute("REPLACE INTO mentor (uid, expertise)
+ VALUES ({?}, {?})",
+ S::i('uid'), $expertise);
+ $this->values['expertise'] = $expertise;
+ }
}
}