本文整理汇总了PHP中get_dbid函数的典型用法代码示例。如果您正苦于以下问题:PHP get_dbid函数的具体用法?PHP get_dbid怎么用?PHP get_dbid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_dbid函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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();
}
示例2: add_script
function add_script($name, $command, $usrgrpid, $groupid, $access)
{
$scriptid = get_dbid('scripts', 'scriptid');
$sql = 'INSERT INTO scripts (scriptid,name,command,usrgrpid,groupid,host_access) ' . " VALUES ({$scriptid}," . zbx_dbstr($name) . ',' . zbx_dbstr($command) . ",{$usrgrpid},{$groupid},{$access})";
$result = DBexecute($sql);
if ($result) {
$result = $scriptid;
}
return $result;
}
示例3: add_expression
function add_expression($regexpid, $expression = array())
{
$db_fields = array('expression' => null, 'expression_type' => null, 'case_sensitive' => 0, 'exp_delimiter' => ',');
if (!check_db_fields($db_fields, $expression)) {
error(S_INCORRECT_ARGUMENTS_PASSED_TO_FUNCTION . ' [add_expression]');
return false;
}
$expressionid = get_dbid('expressions', 'expressionid');
$result = DBexecute('INSERT INTO expressions (expressionid,regexpid,expression,expression_type,case_sensitive,exp_delimiter) ' . ' VALUES (' . $expressionid . ',' . $regexpid . ',' . zbx_dbstr($expression['expression']) . ',' . $expression['expression_type'] . ',' . $expression['case_sensitive'] . ',' . zbx_dbstr($expression['exp_delimiter']) . ')');
return $result ? $expressionid : false;
}
示例4: add_expression
function add_expression($regexpid, $expression = array())
{
$db_fields = array('expression' => null, 'expression_type' => null, 'case_sensitive' => 0, 'exp_delimiter' => ',');
if (!check_db_fields($db_fields, $expression)) {
error('Incorrect arguments pasted to function [add_expression]');
return false;
}
$expressionid = get_dbid('expressions', 'expressionid');
$result = DBexecute('INSERT INTO expressions (expressionid,regexpid,expression,expression_type,case_sensitive,exp_delimiter) ' . ' VALUES (' . $expressionid . ',' . $regexpid . ',' . zbx_dbstr($expression['expression']) . ',' . $expression['expression_type'] . ',' . $expression['case_sensitive'] . ',' . zbx_dbstr($expression['exp_delimiter']) . ')');
return $result ? $expressionid : false;
}
示例5: add_user_to_group
function add_user_to_group($userid, $usrgrpid)
{
$result = false;
if (granted2move_user($userid, $usrgrpid)) {
DBexecute('DELETE FROM users_groups WHERE userid=' . zbx_dbstr($userid) . ' AND usrgrpid=' . zbx_dbstr($usrgrpid));
$users_groups_id = get_dbid('users_groups', 'id');
$result = DBexecute('INSERT INTO users_groups (id,usrgrpid,userid) VALUES (' . $users_groups_id . ',' . zbx_dbstr($usrgrpid) . ',' . zbx_dbstr($userid) . ')');
} else {
error(_('User cannot change status of himself.'));
}
return $result;
}
示例6: add_image
function add_image($name, $imagetype, $file)
{
if (!is_null($file)) {
if ($file["error"] != 0 || $file["size"] == 0) {
error("Incorrect Image");
} else {
if ($file["size"] < 1024 * 1024) {
global $DB;
$imageid = get_dbid("images", "imageid");
$image = fread(fopen($file["tmp_name"], "r"), filesize($file["tmp_name"]));
if ($DB['TYPE'] == "ORACLE") {
DBstart();
$lobimage = OCINewDescriptor($DB['DB'], OCI_D_LOB);
$stid = OCIParse($DB['DB'], "insert into images (imageid,name,imagetype,image)" . " values ({$imageid}," . zbx_dbstr($name) . "," . $imagetype . ",EMPTY_BLOB())" . " return image into :image");
if (!$stid) {
$e = ocierror($stid);
error("Parse SQL error [" . $e["message"] . "] in [" . $e["sqltext"] . "]");
return false;
}
OCIBindByName($stid, ':image', $lobimage, -1, OCI_B_BLOB);
if (!OCIExecute($stid, OCI_DEFAULT)) {
$e = ocierror($stid);
error("Execute SQL error [" . $e["message"] . "] in [" . $e["sqltext"] . "]");
return false;
}
$result = DBend($lobimage->save($image));
if (!$result) {
error("Couldn't save image!\n");
return false;
}
$lobimage->free();
OCIFreeStatement($stid);
return $stid;
} else {
if ($DB['TYPE'] == "POSTGRESQL") {
$image = pg_escape_bytea($image);
} else {
if ($DB['TYPE'] == "SQLITE3") {
$image = bin2hex($image);
}
}
}
return DBexecute("insert into images (imageid,name,imagetype,image)" . " values ({$imageid}," . zbx_dbstr($name) . "," . $imagetype . "," . zbx_dbstr($image) . ")");
} else {
error("Image size must be less than 1Mb");
}
}
} else {
error("Select image to download");
}
return false;
}
示例7: add_acknowledge_coment
function add_acknowledge_coment($eventid, $userid, $message)
{
$result = set_event_acnowledged($eventid);
if (!$result) {
return $result;
}
$acknowledgeid = get_dbid("acknowledges", "acknowledgeid");
$result = DBexecute("insert into acknowledges (acknowledgeid,userid,eventid,clock,message)" . " values ({$acknowledgeid},{$userid},{$eventid}," . time() . "," . zbx_dbstr($message) . ")");
if (!$result) {
return $result;
}
return $acknowledgeid;
}
示例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);
}
$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 DBexecute('INSERT INTO profiles (' . implode(', ', array_keys($values)) . ')' . ' VALUES (' . implode(', ', $values) . ')');
}
示例10: add_valuemap
function add_valuemap($name, $mappings)
{
if (!is_array($mappings)) {
return FALSE;
}
$valuemapid = get_dbid("valuemaps", "valuemapid");
$result = DBexecute("insert into valuemaps (valuemapid,name) values ({$valuemapid}," . zbx_dbstr($name) . ")");
if (!$result) {
return $result;
}
$result = add_mapping_to_valuemap($valuemapid, $mappings);
if (!$result) {
delete_valuemap($valuemapid);
} else {
$result = $valuemapid;
}
return $result;
}
示例11: add_service_alarm
function add_service_alarm($serviceid, $status, $clock)
{
if (latest_service_alarm($serviceid, $status)) {
return true;
}
$result = DBexecute('INSERT INTO service_alarms (servicealarmid,serviceid,clock,value) VALUES (' . get_dbid('service_alarms', 'servicealarmid') . ',' . $serviceid . ',' . $clock . ',' . $status . ')');
return $result;
}
示例12: update_slideshow
function update_slideshow($slideshowid, $name, $delay, $slides)
{
// validate slides
if (empty($slides)) {
error(_('Slide show must contain slides.'));
return false;
}
// validate screens
$screenids = zbx_objectValues($slides, 'screenid');
$screens = API::Screen()->get(array('screenids' => $screenids, 'output' => array('screenid')));
$screens = ZBX_toHash($screens, 'screenid');
foreach ($screenids as $screenid) {
if (!isset($screens[$screenid])) {
error(_('Incorrect screen provided for slide show.'));
return false;
}
}
// validate slide name
$db_slideshow = DBfetch(DBselect('SELECT s.slideshowid' . ' FROM slideshows s' . ' WHERE s.name=' . zbx_dbstr($name) . ' AND s.slideshowid<>' . zbx_dbstr($slideshowid) . ' ' . andDbNode('s.slideshowid')));
if (!empty($db_slideshow)) {
error(_s('Slide show "%s" already exists.', $name));
return false;
}
$db_slideshow = DBfetchArray(DBselect('SELECT * FROM slideshows WHERE slideshowid=' . zbx_dbstr($slideshowid)));
$db_slideshow = $db_slideshow[0];
$changed = false;
$slideshow = array('name' => $name, 'delay' => $delay);
foreach ($slideshow as $key => $val) {
if ($db_slideshow[$key] != $val) {
$changed = true;
break;
}
}
if ($changed) {
if (!($result = DBexecute('UPDATE slideshows SET name=' . zbx_dbstr($name) . ',delay=' . zbx_dbstr($delay) . ' WHERE slideshowid=' . zbx_dbstr($slideshowid)))) {
return false;
}
}
// get slides
$db_slides = DBfetchArrayAssoc(DBselect('SELECT s.* FROM slides s WHERE s.slideshowid=' . zbx_dbstr($slideshowid)), 'slideid');
$slidesToDel = zbx_objectValues($db_slides, 'slideid');
$slidesToDel = zbx_toHash($slidesToDel);
$step = 0;
foreach ($slides as $slide) {
$slide['delay'] = $slide['delay'] ? $slide['delay'] : 0;
if (isset($db_slides[$slide['slideid']])) {
// update slide
if ($db_slides[$slide['slideid']]['delay'] != $slide['delay'] || $db_slides[$slide['slideid']]['step'] != $step) {
$result = DBexecute('UPDATE slides SET step=' . zbx_dbstr($step) . ', delay=' . zbx_dbstr($slide['delay']) . ' WHERE slideid=' . zbx_dbstr($slide['slideid']));
} else {
$result = true;
}
unset($slidesToDel[$slide['slideid']]);
} else {
$slideid = get_dbid('slides', 'slideid');
$result = DBexecute('INSERT INTO slides (slideid,slideshowid,screenid,step,delay)' . ' VALUES (' . zbx_dbstr($slideid) . ',' . zbx_dbstr($slideshowid) . ',' . zbx_dbstr($slide['screenid']) . ',' . zbx_dbstr($step) . ',' . zbx_dbstr($slide['delay']) . ')');
}
$step++;
if (!$result) {
return false;
}
}
// delete unnecessary slides
if (!empty($slidesToDel)) {
DBexecute('DELETE FROM slides WHERE slideid IN(' . implode(',', $slidesToDel) . ')');
}
return true;
}
示例13: insert_dependency
function insert_dependency($triggerid_down, $triggerid_up)
{
$triggerdepid = get_dbid("trigger_depends", "triggerdepid");
$result = DBexecute("insert into trigger_depends (triggerdepid,triggerid_down,triggerid_up)" . " values ({$triggerdepid},{$triggerid_down},{$triggerid_up})");
if (!$result) {
return $result;
}
return DBexecute("update triggers set dep_level=dep_level+1 where triggerid={$triggerid_up}");
}
示例14: create
/**
* Add images.
*
* @param array $images ['name' => string, 'image' => string, 'imagetype' => int]
*
* @return array
*/
public function create($images)
{
global $DB;
$images = zbx_toArray($images);
$this->validateCreate($images);
$imageids = array();
foreach ($images as $image) {
// decode BASE64
$image['image'] = base64_decode($image['image']);
// validate image (size and format)
$this->checkImage($image['image']);
$imageid = get_dbid('images', 'imageid');
$values = array('imageid' => $imageid, 'name' => zbx_dbstr($image['name']), 'imagetype' => zbx_dbstr($image['imagetype']));
switch ($DB['TYPE']) {
case ZBX_DB_ORACLE:
$values['image'] = 'EMPTY_BLOB()';
$lob = oci_new_descriptor($DB['DB'], OCI_D_LOB);
$sql = 'INSERT INTO images (' . implode(' ,', array_keys($values)) . ') VALUES (' . implode(',', $values) . ')' . ' returning image into :imgdata';
$stmt = oci_parse($DB['DB'], $sql);
if (!$stmt) {
$e = oci_error($DB['DB']);
self::exception(ZBX_API_ERROR_PARAMETERS, _s('Parse SQL error [%1$s] in [%2$s].', $e['message'], $e['sqltext']));
}
oci_bind_by_name($stmt, ':imgdata', $lob, -1, OCI_B_BLOB);
if (!oci_execute($stmt, OCI_DEFAULT)) {
$e = oci_error($stmt);
self::exception(ZBX_API_ERROR_PARAMETERS, _s('Execute SQL error [%1$s] in [%2$s].', $e['message'], $e['sqltext']));
}
if (!$lob->save($image['image'])) {
$e = oci_error($stmt);
self::exception(ZBX_API_ERROR_PARAMETERS, _s('Image load error [%1$s] in [%2$s].', $e['message'], $e['sqltext']));
}
$lob->free();
oci_free_statement($stmt);
break;
case ZBX_DB_DB2:
$stmt = db2_prepare($DB['DB'], 'INSERT INTO images (' . implode(' ,', array_keys($values)) . ',image)' . ' VALUES (' . implode(',', $values) . ', ?)');
if (!$stmt) {
self::exception(ZBX_API_ERROR_PARAMETERS, db2_conn_errormsg($DB['DB']));
}
$variable = $image['image'];
if (!db2_bind_param($stmt, 1, "variable", DB2_PARAM_IN, DB2_BINARY)) {
self::exception(ZBX_API_ERROR_PARAMETERS, db2_conn_errormsg($DB['DB']));
}
if (!db2_execute($stmt)) {
self::exception(ZBX_API_ERROR_PARAMETERS, db2_conn_errormsg($DB['DB']));
}
break;
case ZBX_DB_SQLITE3:
$values['image'] = zbx_dbstr(bin2hex($image['image']));
$sql = 'INSERT INTO images (' . implode(', ', array_keys($values)) . ') VALUES (' . implode(', ', $values) . ')';
if (!DBexecute($sql)) {
self::exception(ZBX_API_ERROR_PARAMETERS, 'DBerror');
}
break;
case ZBX_DB_MYSQL:
$values['image'] = zbx_dbstr($image['image']);
$sql = 'INSERT INTO images (' . implode(', ', array_keys($values)) . ') VALUES (' . implode(', ', $values) . ')';
if (!DBexecute($sql)) {
self::exception(ZBX_API_ERROR_PARAMETERS, 'DBerror');
}
break;
case ZBX_DB_POSTGRESQL:
$values['image'] = "'" . pg_escape_bytea($image['image']) . "'";
$sql = 'INSERT INTO images (' . implode(', ', array_keys($values)) . ') VALUES (' . implode(', ', $values) . ')';
if (!DBexecute($sql)) {
self::exception(ZBX_API_ERROR_PARAMETERS, 'DBerror');
}
break;
}
$imageids[] = $imageid;
}
return array('imageids' => $imageids);
}
示例15: add_action
function add_action($name, $eventsource, $esc_period, $def_shortdata, $def_longdata, $recovery_msg, $r_shortdata, $r_longdata, $evaltype, $status, $conditions, $operations)
{
if (!is_array($conditions) || count($conditions) == 0) {
/*
error(S_NO_CONDITIONS_DEFINED);
return false;
*/
} else {
if (!check_permission_for_action_conditions($conditions)) {
return false;
}
foreach ($conditions as $condition) {
if (!validate_condition($condition['type'], $condition['value'])) {
return false;
}
}
}
if (!is_array($operations) || count($operations) == 0) {
error(S_NO_OPERATIONS_DEFINED);
return false;
}
foreach ($operations as $operation) {
if (!validate_operation($operation)) {
return false;
}
}
$actionid = get_dbid('actions', 'actionid');
$result = DBexecute('INSERT INTO actions (actionid,name,eventsource,esc_period,def_shortdata,def_longdata,recovery_msg,r_shortdata,r_longdata,evaltype,status)' . ' VALUES (' . $actionid . ',' . zbx_dbstr($name) . ',' . $eventsource . ',' . $esc_period . ',' . zbx_dbstr($def_shortdata) . ',' . zbx_dbstr($def_longdata) . ',' . $recovery_msg . ',' . zbx_dbstr($r_shortdata) . ',' . zbx_dbstr($r_longdata) . ',' . $evaltype . ',' . $status . ')');
if (!$result) {
return $result;
}
foreach ($operations as $operation) {
if (!($result = add_action_operation($actionid, $operation))) {
break;
}
}
if ($result) {
foreach ($conditions as $condition) {
if (!($result = add_action_condition($actionid, $condition))) {
break;
}
}
}
return $actionid;
}