本文整理匯總了PHP中DBstart函數的典型用法代碼示例。如果您正苦於以下問題:PHP DBstart函數的具體用法?PHP DBstart怎麽用?PHP DBstart使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了DBstart函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: doAction
protected function doAction()
{
$idx = $this->getInput('idx');
$value_int = $this->getInput('value_int');
DBstart();
switch ($idx) {
case 'web.latest.toggle':
case 'web.latest.toggle_other':
if ($value_int == 1) {
// default value
CProfile::delete($idx, $this->getInput('idx2'));
} else {
foreach ($this->getInput('idx2') as $idx2) {
CProfile::update($idx, $value_int, PROFILE_TYPE_INT, $idx2);
}
}
break;
default:
if ($value_int == 1) {
// default value
CProfile::delete($idx);
} else {
CProfile::update($idx, $value_int, PROFILE_TYPE_INT);
}
}
DBend();
$this->setResponse(new CControllerResponseData(['main_block' => '']));
}
示例2: doAction
protected function doAction()
{
$script = [];
$this->getInputs($script, ['scriptid', 'name', 'type', 'execute_on', 'command', 'description', 'usrgrpid', 'groupid', 'host_access']);
$script['confirmation'] = $this->getInput('confirmation', '');
if ($this->getInput('type', ZBX_SCRIPT_TYPE_CUSTOM_SCRIPT) == ZBX_SCRIPT_TYPE_IPMI && $this->hasInput('commandipmi')) {
$script['command'] = $this->getInput('commandipmi');
}
if ($this->getInput('hgstype', 1) == 0) {
$script['groupid'] = 0;
}
DBstart();
$result = API::Script()->update($script);
if ($result) {
$scriptId = reset($result['scriptids']);
add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_SCRIPT, 'Name [' . $this->getInput('name', '') . '] id [' . $scriptId . ']');
}
$result = DBend($result);
if ($result) {
$response = new CControllerResponseRedirect('zabbix.php?action=script.list&uncheck=1');
$response->setMessageOk(_('Script updated'));
} else {
$response = new CControllerResponseRedirect('zabbix.php?action=script.edit&scriptid=' . $this->getInput('scriptid'));
$response->setFormData($this->getInputAll());
$response->setMessageError(_('Cannot update script'));
}
$this->setResponse($response);
}
示例3: flush
public static function flush()
{
// if not initialised, no changes were made
if (is_null(self::$profiles)) {
return true;
}
if (self::$userDetails['userid'] <= 0) {
return null;
}
if (!empty(self::$insert) || !empty(self::$update)) {
DBstart();
foreach (self::$insert as $idx => $profile) {
foreach ($profile as $idx2 => $data) {
self::insertDB($idx, $data['value'], $data['type'], $idx2);
}
}
ksort(self::$update);
foreach (self::$update as $idx => $profile) {
ksort($profile);
foreach ($profile as $idx2 => $data) {
self::updateDB($idx, $data['value'], $data['type'], $idx2);
}
}
DBend();
}
}
示例4: doAction
protected function doAction()
{
$proxy = [];
$this->getInputs($proxy, ['host', 'status', 'description', 'tls_connect', 'tls_accept', 'tls_issuer', 'tls_subject', 'tls_psk_identity', 'tls_psk']);
if ($this->getInput('status', HOST_STATUS_PROXY_ACTIVE) == HOST_STATUS_PROXY_PASSIVE) {
$proxy['interface'] = [];
$this->getInputs($proxy['interface'], ['dns', 'ip', 'useip', 'port']);
}
DBstart();
if ($this->hasInput('proxy_hostids')) {
// skip discovered hosts
$proxy['hosts'] = API::Host()->get(['output' => ['hostid'], 'hostids' => $this->getInput('proxy_hostids'), 'filter' => ['flags' => ZBX_FLAG_DISCOVERY_NORMAL]]);
}
$result = API::Proxy()->create([$proxy]);
if ($result) {
add_audit(AUDIT_ACTION_ADD, AUDIT_RESOURCE_PROXY, '[' . $this->getInput('host', '') . '] [' . reset($result['proxyids']) . ']');
}
$result = DBend($result);
if ($result) {
$response = new CControllerResponseRedirect('zabbix.php?action=proxy.list&uncheck=1');
$response->setMessageOk(_('Proxy added'));
} else {
$response = new CControllerResponseRedirect('zabbix.php?action=proxy.edit');
$response->setFormData($this->getInputAll());
$response->setMessageError(_('Cannot add proxy'));
}
$this->setResponse($response);
}
示例5: transactionBegin
private static function transactionBegin()
{
global $DB;
if ($DB['TRANSACTIONS'] == 0) {
DBstart();
self::$transactionStarted = true;
}
}
示例6: update_node_profile
function update_node_profile($nodeids)
{
DBstart();
DBexecute('DELETE FROM profiles WHERE userid=' . CWebUser::$data['userid'] . ' AND idx=' . zbx_dbstr('web.nodes.selected'));
foreach ($nodeids as $nodeid) {
DBexecute('INSERT INTO profiles (profileid,userid,idx,value_id,type)' . ' VALUES (' . get_dbid('profiles', 'profileid') . ',' . CWebUser::$data['userid'] . ',' . zbx_dbstr('web.nodes.selected') . ',' . $nodeid . ',4)');
}
DBend();
}
示例7: doAction
protected function doAction()
{
$mediatype = [];
$this->getInputs($mediatype, ['type', 'description', 'status']);
switch ($mediatype['type']) {
case MEDIA_TYPE_EMAIL:
$this->getInputs($mediatype, ['smtp_server', 'smtp_port', 'smtp_helo', 'smtp_email', 'smtp_security', 'smtp_verify_peer', 'smtp_verify_host', 'smtp_authentication', 'passwd']);
if ($this->hasInput('smtp_username')) {
$mediatype['username'] = $this->getInput('smtp_username');
}
break;
case MEDIA_TYPE_EXEC:
$this->getInputs($mediatype, ['exec_path']);
$mediatype['exec_params'] = '';
if ($this->hasInput('exec_params')) {
$exec_params = zbx_objectValues($this->getInput('exec_params'), 'exec_param');
foreach ($exec_params as $exec_param) {
$mediatype['exec_params'] .= $exec_param . "\n";
}
}
break;
case MEDIA_TYPE_SMS:
$this->getInputs($mediatype, ['gsm_modem']);
break;
case MEDIA_TYPE_JABBER:
$this->getInputs($mediatype, ['passwd']);
if ($this->hasInput('jabber_username')) {
$mediatype['username'] = $this->getInput('jabber_username');
}
break;
case MEDIA_TYPE_EZ_TEXTING:
$this->getInputs($mediatype, ['passwd']);
if ($this->hasInput('eztext_username')) {
$mediatype['username'] = $this->getInput('eztext_username');
}
if ($this->hasInput('eztext_limit')) {
$mediatype['exec_path'] = $this->getInput('eztext_limit');
}
break;
}
DBstart();
$result = API::Mediatype()->create($mediatype);
if ($result) {
add_audit(AUDIT_ACTION_ADD, AUDIT_RESOURCE_MEDIA_TYPE, 'Media type [' . $mediatype['description'] . ']');
}
$result = DBend($result);
if ($result) {
$response = new CControllerResponseRedirect('zabbix.php?action=mediatype.list&uncheck=1');
$response->setMessageOk(_('Media type added'));
} else {
$response = new CControllerResponseRedirect('zabbix.php?action=mediatype.edit');
$response->setFormData($this->getInputAll());
$response->setMessageError(_('Cannot add media type'));
}
$this->setResponse($response);
}
示例8: update_node_profile
function update_node_profile($nodeids)
{
global $USER_DETAILS;
DBstart();
$sql = 'DELETE FROM profiles WHERE userid=' . $USER_DETAILS['userid'] . ' AND idx=' . zbx_dbstr('web.nodes.selected');
DBexecute($sql);
foreach ($nodeids as $nodeid) {
$profileid = get_dbid('profiles', 'profileid');
$sql = 'INSERT INTO profiles (profileid, userid, idx, value_id, type)' . ' VALUES (' . $profileid . ',' . $USER_DETAILS['userid'] . ', ' . zbx_dbstr('web.nodes.selected') . ',' . $nodeid . ', 4)';
DBexecute($sql);
}
DBend();
}
示例9: add
/**
* Adds favorite value to DB.
*
* @param string $idx identifier of favorite value group
* @param int $favid value id
* @param string $favobj source object
*
* @return bool did SQL INSERT succeeded
*/
public static function add($idx, $favid, $favobj = null)
{
if (self::exists($idx, $favid, $favobj)) {
return true;
}
// add to cache only if cache is created
if (isset(self::$cache[$idx])) {
self::$cache[$idx][] = array('value' => $favid, 'source' => $favobj);
}
DBstart();
$values = array('profileid' => get_dbid('profiles', 'profileid'), 'userid' => CWebUser::$data['userid'], 'idx' => zbx_dbstr($idx), 'value_id' => zbx_dbstr($favid), 'type' => PROFILE_TYPE_ID);
if (!is_null($favobj)) {
$values['source'] = zbx_dbstr($favobj);
}
return DBend(DBexecute('INSERT INTO profiles (' . implode(', ', array_keys($values)) . ') VALUES (' . implode(', ', $values) . ')'));
}
示例10: doAction
protected function doAction()
{
$profile = ['graphid' => 'web.favorite.graphids', 'itemid' => 'web.favorite.graphids', 'screenid' => 'web.favorite.screenids', 'slideshowid' => 'web.favorite.screenids', 'sysmapid' => 'web.favorite.sysmapids'];
$object = $this->getInput('object');
$objectid = $this->getInput('objectid');
$data = [];
DBstart();
$result = CFavorite::remove($profile[$object], $objectid, $object);
$result = DBend($result);
if ($result) {
$data['main_block'] = '$("addrm_fav").title = "' . _('Add to favourites') . '";' . "\n" . '$("addrm_fav").onclick = function() { add2favorites("' . $object . '", "' . $objectid . '"); }' . "\n" . 'switchElementClass("addrm_fav", "btn-remove-fav", "btn-add-fav");';
} else {
$data['main_block'] = '';
}
$this->setResponse(new CControllerResponseData($data));
}
示例11: flush
public static function flush()
{
if (!empty(self::$insert) || !empty(self::$update)) {
DBstart();
foreach (self::$insert as $idx => $profile) {
foreach ($profile as $idx2 => $data) {
$result = self::insertDB($idx, $data['value'], $data['type'], $idx2);
}
}
ksort(self::$update);
foreach (self::$update as $idx => $profile) {
ksort($profile);
foreach ($profile as $idx2 => $data) {
self::updateDB($idx, $data['value'], $data['type'], $idx2);
}
}
DBend();
}
}
示例12: doAction
protected function doAction()
{
$scriptids = $this->getInput('scriptids');
DBstart();
$result = API::Script()->delete($scriptids);
if ($result) {
foreach ($scriptids as $scriptid) {
add_audit(AUDIT_ACTION_DELETE, AUDIT_RESOURCE_SCRIPT, _('Script') . ' [' . $scriptid . ']');
}
}
$result = DBend($result);
$deleted = count($scriptids);
$response = new CControllerResponseRedirect('zabbix.php?action=script.list&uncheck=1');
if ($result) {
$response->setMessageOk(_n('Script deleted', 'Scripts deleted', $deleted));
} else {
$response->setMessageError(_n('Cannot delete script', 'Cannot delete scripts', $deleted));
}
$this->setResponse($response);
}
示例13: BeginTransaction
protected static function BeginTransaction($caller = 'CZBXAPI')
{
global $DB;
if (!isset(self::$transaction[$caller])) {
self::$transaction[$caller] = 0;
}
self::$transaction[$caller]++;
//SDII(self::$transaction);
if (self::$transaction['counter'] > 0) {
self::$transaction['counter']++;
} else {
if ($DB['TRANSACTIONS'] == 0) {
DBstart();
self::$transaction['counter'] = 1;
self::$transaction['owner'] = $caller;
} else {
self::$transaction['counter'] = 2;
self::$transaction['owner'] = 'DB_CLASS';
}
}
//SDII(self::$transaction);
return true;
}
示例14: delete
/**
* Delete Users
*
* @static
* @param array $userids
* @return boolean
*/
public static function delete($userids)
{
$result = false;
DBstart(false);
foreach ($userids as $userid) {
$result = delete_user($userid);
if (!$resukt) {
break;
}
}
DBend($result);
if ($result) {
return true;
} else {
self::$error = array('error' => ZBX_API_ERROR_INTERNAL, 'data' => 'Internal zabbix error');
return false;
}
}
示例15: addItems
/**
* Add items to graph
*
* <code>
* $items = array(
* *string 'graphid' => null,
* array 'items' => (
* 'item1' => array(
* *int 'itemid' => null,
* int 'color' => '000000',
* int 'drawtype' => 0,
* int 'sortorder' => 0,
* int 'yaxisside' => 1,
* int 'calc_fnc' => 2,
* int 'type' => 0,
* int 'periods_cnt' => 5,
* ), ... )
* );
* </code>
*
* @static
* @param array $items multidimensional array with items data
* @return boolean
*/
public static function addItems($items)
{
$error = 'Unknown ZABBIX internal error';
$result_ids = array();
$result = false;
$tpl_graph = false;
$graphid = $items['graphid'];
$items_tmp = $items['items'];
$items = array();
$itemids = array();
foreach ($items_tmp as $item) {
$graph_db_fields = array('itemid' => null, 'color' => '000000', 'drawtype' => 0, 'sortorder' => 0, 'yaxisside' => 1, 'calc_fnc' => 2, 'type' => 0, 'periods_cnt' => 5);
if (!check_db_fields($graph_db_fields, $item)) {
self::$error = array('error' => ZBX_API_ERROR_INTERNAL, 'data' => 'Wrong fields for item [ ' . $item['itemid'] . ' ]');
return false;
}
$items[$item['itemid']] = $item;
$itemids[$item['itemid']] = $item['itemid'];
}
// check if graph is templated graph, then items cannot be added
$graph = CGraph::getById(array('graphid' => $graphid));
if ($graph['templateid'] != 0) {
self::$error = array('error' => ZBX_API_ERROR_INTERNAL, 'data' => 'Cannot edit templated graph : ' . $graph['name']);
return false;
}
// check if graph belongs to template, if so, only items from same template can be added
$tmp_hosts = get_hosts_by_graphid($graphid);
$host = DBfetch($tmp_hosts);
// if graph belongs to template, only one host is possible
if ($host["status"] == HOST_STATUS_TEMPLATE) {
$sql = 'SELECT DISTINCT count(i.hostid) as count
FROM items i
WHERE i.hostid<>' . $host['hostid'] . ' AND ' . DBcondition('i.itemid', $itemids);
$host_count = DBfetch(DBselect($sql));
if ($host_count['count']) {
self::$error = array('error' => ZBX_API_ERROR_INTERNAL, 'data' => 'You must use items only from host : ' . $host['host'] . ' for template graph : ' . $graph['name']);
return false;
}
$tpl_graph = true;
}
DBstart(false);
$result = self::addItems_rec($graphid, $items, $tpl_graph);
$result = DBend($result);
if ($result) {
return $result;
} else {
self::$error = array('error' => ZBX_API_ERROR_INTERNAL, 'data' => $error);
//'Internal zabbix error');
return false;
}
}