Source
return DBexecute('INSERT INTO profiles ('.implode(', ', array_keys($values)).') VALUES ('.implode(', ', $values).')');
<?php
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
class CProfile {
private static $userDetails = [];
private static $profiles = null;
private static $update = [];
private static $insert = [];
private static $stringProfileMaxLength;
private static $is_initialized = false;
public static function init() {
self::$userDetails = CWebUser::$data;
self::$profiles = [];
self::$stringProfileMaxLength = DB::getFieldLength('profiles', 'value_str');
DBselect('SELECT NULL FROM users u WHERE '.dbConditionId('u.userid', (array) self::$userDetails['userid']).
' FOR UPDATE'
);
if (!self::$is_initialized) {
register_shutdown_function(function() {
DBstart();
$result = self::flush();
DBend($result);
});
}
self::$is_initialized = true;
}
/**
* Check if data needs to be inserted or updated.
*
* @return bool
*/
public static function isModified() {
return (self::$insert || self::$update);
}
public static function flush() {
$result = false;
if (self::$profiles !== null && self::$userDetails['userid'] > 0 && self::isModified()) {
$result = true;
foreach (self::$insert as $idx => $profile) {
foreach ($profile as $idx2 => $data) {
if (!self::insertDB($idx, $data['value'], $data['type'], $idx2)) {