OTS_Account: setCustomField - Use Account model to update

This commit is contained in:
slawkens
2026-01-20 22:26:08 +01:00
parent a44e2d6ebe
commit 1975fb8ebe

View File

@@ -12,6 +12,7 @@
* @license http://www.gnu.org/licenses/lgpl-3.0.txt GNU Lesser General Public License, Version 3 * @license http://www.gnu.org/licenses/lgpl-3.0.txt GNU Lesser General Public License, Version 3
*/ */
use MyAAC\Models\Account as AccountModel;
use MyAAC\Models\AccountAction; use MyAAC\Models\AccountAction;
/** /**
@@ -702,17 +703,11 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
*/ */
public function setCustomField($field, $value) public function setCustomField($field, $value)
{ {
if( !isset($this->data['id']) ) if( !isset($this->data['id']) ) {
{
throw new E_OTS_NotLoaded(); throw new E_OTS_NotLoaded();
} }
// quotes value for SQL query AccountModel::where('id', $this->data['id'])->update([$field => $value]);
if(!( is_int($value) || is_float($value) ))
{
$value = $this->db->quote($value);
}
$this->db->exec('UPDATE ' . $this->db->tableName('accounts') . ' SET ' . $this->db->fieldName($field) . ' = ' . $value . ' WHERE ' . $this->db->fieldName('id') . ' = ' . $this->data['id']);
} }
/** /**