本文整理汇总了PHP中update_item函数的典型用法代码示例。如果您正苦于以下问题:PHP update_item函数的具体用法?PHP update_item怎么用?PHP update_item使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了update_item函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRemoveItemWhenSetPrivate
/**
* When an existing item is switched from public to private, it should be
* removed from Solr.
*/
public function testRemoveItemWhenSetPrivate()
{
// Insert public item.
$item = insert_item(array('public' => true));
// Set the item private.
update_item($item, array('public' => false));
// Should remove the Solr document.
$this->_assertNotRecordInSolr($item);
}
示例2: testHookAfterSaveItem
/**
* `hookAfterSaveItem` should update records that reference the item.
*/
public function testHookAfterSaveItem()
{
$item = $this->_item('title');
$exhibit = $this->_exhibit();
$record = $this->_record($exhibit, $item);
// Update the item.
update_item($item, array(), array('Dublin Core' => array('Title' => array(array('text' => 'title', 'html' => false)))));
// Record should be compiled.
$record = $this->_reload($record);
$this->assertEquals('title', $record->item_title);
}
示例3: process_item
function process_item($window, $id)
{
global $mainwin;
switch ($id) {
case IDOK:
if (update_item($window)) {
wb_destroy_window($window);
update_items($mainwin);
}
break;
case IDCANCEL:
case IDCLOSE:
wb_destroy_window($window);
break;
}
}
示例4: add_item
function add_item(&$cart, $key, $quantity)
{
global $products;
if ($quantity < 1) {
return;
}
// If item already exists in cart, update quantity
if (isset($cart[$key])) {
$quantity += $cart[$key]['qty'];
update_item($cart, $key, $quantity);
return;
}
// Add item
$cost = $products[$key]['cost'];
$total = $cost * $quantity;
$item = array('name' => $products[$key]['name'], 'cost' => $cost, 'qty' => $quantity, 'total' => $total);
$cart[$key] = $item;
}
示例5: import
public function import()
{
//grab the data needed for using update_item or insert_item
$elementTexts = $this->elementTexts();
$itemMetadata = $this->itemMetadata();
//avoid accidental duplications
if ($this->record && $this->record->exists()) {
$itemMetadata['overwriteElementTexts'] = true;
update_item($this->record, $itemMetadata, $elementTexts);
$this->updateItemOwner($this->record);
} else {
$this->record = insert_item($itemMetadata, $elementTexts);
//dig up the correct owner information, importing the user if needed
$this->updateItemOwner($this->record);
$this->addOmekaApiImportRecordIdMap();
}
//import files after the item is there, so the file has an item id to use
//we're also keeping track of the correspondences between local and remote
//file ids, so we have to introduce this little inefficiency of not passing
//the file data
$this->importFiles($this->record);
}
示例6: unrateAction
public function unrateAction()
{
$db = $this->_helper->db->getTable('Ratings');
// Allow only AJAX requests.
if (!$this->getRequest()->isXmlHttpRequest()) {
$this->_helper->redirector->gotoUrl('/');
}
$record_id = $this->_getParam('record_id');
$user_id = $this->_getParam('user_id');
// validation needed?
if (isset($record_id) && isset($user_id)) {
$this->_helper->db->getTable('Ratings')->removeRating($record_id, $user_id);
}
// update AVG rating
$avgRating = $db->getAvgRating($record_id);
// Get Item
$item = get_record_by_id('Item', $record_id);
// Update the average rating for this item
$metaData = array('overwriteElementTexts' => true);
$elementText = array('Ratings' => array('Average Rating' => array(array('text' => $avgRating, 'html' => false))));
$itemUpdated = update_item($item, $metaData, $elementText);
}
示例7: perform
public function perform()
{
if (!($itemIds = $this->_options['itemIds'])) {
return;
}
$delete = $this->_options['delete'];
$metadata = $this->_options['metadata'];
$custom = $this->_options['custom'];
foreach ($itemIds as $id) {
$item = $this->_getItem($id);
if ($delete == '1') {
$item->delete();
} else {
foreach ($metadata as $key => $value) {
if ($value === '') {
unset($metadata[$key]);
}
}
update_item($item, $metadata);
fire_plugin_hook('items_batch_edit_custom', array('item' => $item, 'custom' => $custom));
}
release_object($item);
}
}
示例8: update
}
}
} else {
$data = " menu_name = '{$i_name}', \n\t\t\t\t\t\t\tmenu_type_id = '{$i_menu_type_id}',\n\t\t\t\t\t\t\tmenu_original_price = '{$i_original_price}',\n\t\t\t\t\t\t\tmenu_margin_price = '{$i_margin_price}',\n\t\t\t\t\t\t\tmenu_price = '{$i_price}',\n\t\t\t\t\t\t\tpartner_id = '{$i_partner_id}',\n\t\t\t\t\t\t\tout_time = '{$i_out_time}'\n\t\t\t\t\t";
}
update($data, $id);
header('Location: menu.php?page=list&did=2');
break;
case 'edit_item':
extract($_POST);
$id = get_isset($_GET['id']);
$menu_id = get_isset($_GET['menu_id']);
$i_item_id = get_isset($i_item_id);
$i_item_qty = get_isset($i_item_qty);
$data = " item_id = '{$i_item_id}', \n\t\t\t\t\t\t\titem_qty = '{$i_item_qty}'\n\t\t\t\t\t";
update_item($data, $id);
header("Location: menu.php?page=form&id={$menu_id}");
break;
case 'delete':
$id = get_isset($_GET['id']);
$path = "../img/menu/";
$get_img_old = get_img_old($id);
if ($get_img_old) {
if (file_exists($path . $get_img_old)) {
unlink($path . $get_img_old);
}
}
delete($id);
header('Location: menu.php?page=list&did=3');
break;
case 'delete_item':
示例9: update
/**
* Update item
*
* {@source}
* @access public
* @static
* @since 1.8
* @version 1
*
* @static
* @param array $items multidimensional array with items data
* @return boolean
*/
public static function update($items)
{
$result = false;
$itemids = array();
DBstart(false);
foreach ($items as $item) {
$result = update_item($item['itemid'], $item);
if (!$result) {
break;
}
$itemids[$result] = $result;
}
$result = DBend($result);
if ($result) {
return $itemids;
} else {
self::$error = array('error' => ZBX_API_ERROR_INTERNAL, 'data' => 'Internal zabbix error');
return false;
}
}
示例10: db_save_httptest
function db_save_httptest($httptestid, $hostid, $application, $name, $delay, $status, $agent, $macros, $steps)
{
$history = 30;
// TODO !!! Allow user set this parametr
$trends = 90;
// TODO !!! Allow user set this parametr
if (!eregi('^([0-9a-zA-Z\\_\\.[.-.]\\$ ]+)$', $name)) {
error("Scenario name should contain '0-9a-zA-Z_.\$ '- characters only");
return false;
}
DBstart();
if ($applicationid = DBfetch(DBselect('select applicationid from applications ' . ' where name=' . zbx_dbstr($application) . ' and hostid=' . $hostid))) {
$applicationid = $applicationid['applicationid'];
} else {
$applicationid = add_application($application, $hostid);
if (!$applicationid) {
error('Can\'t add new application. [' . $application . ']');
return false;
}
}
if (isset($httptestid)) {
$result = DBexecute('update httptest set ' . ' applicationid=' . $applicationid . ', name=' . zbx_dbstr($name) . ', delay=' . $delay . ',' . ' status=' . $status . ', agent=' . zbx_dbstr($agent) . ', macros=' . zbx_dbstr($macros) . ',' . ' error=' . zbx_dbstr('') . ', curstate=' . HTTPTEST_STATE_UNKNOWN . ' where httptestid=' . $httptestid);
} else {
$httptestid = get_dbid("httptest", "httptestid");
if (DBfetch(DBselect('select t.httptestid from httptest t, applications a where t.applicationid=a.applicationid ' . ' and a.hostid=' . $hostid . ' and t.name=' . zbx_dbstr($name)))) {
error('Scenario with name [' . $name . '] already exist');
return false;
}
$result = DBexecute('insert into httptest' . ' (httptestid, applicationid, name, delay, status, agent, macros, curstate) ' . ' values (' . $httptestid . ',' . $applicationid . ',' . zbx_dbstr($name) . ',' . $delay . ',' . $status . ',' . zbx_dbstr($agent) . ',' . zbx_dbstr($macros) . ',' . HTTPTEST_STATE_UNKNOWN . ')');
$test_added = true;
}
if ($result) {
$httpstepids = array();
foreach ($steps as $sid => $s) {
if (!isset($s['name'])) {
$s['name'] = '';
}
if (!isset($s['timeout'])) {
$s['timeout'] = 15;
}
if (!isset($s['url'])) {
$s['url'] = '';
}
if (!isset($s['posts'])) {
$s['posts'] = '';
}
if (!isset($s['required'])) {
$s['required'] = '';
}
if (!isset($s['status_codes'])) {
$s['status_codes'] = '';
}
$result = db_save_step($hostid, $applicationid, $httptestid, $name, $s['name'], $sid + 1, $s['timeout'], $s['url'], $s['posts'], $s['required'], $s['status_codes'], $delay, $history, $trends);
if (!$result) {
break;
}
$httpstepids[$result] = $result;
}
if ($result) {
/* clean unneeded steps */
$db_steps = DBselect('select httpstepid from httpstep where httptestid=' . $httptestid);
while ($step_data = DBfetch($db_steps)) {
if (isset($httpstepids[$step_data['httpstepid']])) {
continue;
}
delete_httpstep($step_data['httpstepid']);
}
}
}
if ($result) {
$monitored_items = array(array('description' => 'Download speed for scenario \'$1\'', 'key_' => 'web.test.in[' . $name . ',,bps]', 'type' => ITEM_VALUE_TYPE_FLOAT, 'units' => 'bps', 'httptestitemtype' => HTTPSTEP_ITEM_TYPE_IN), array('description' => 'Failed step of scenario \'$1\'', 'key_' => 'web.test.fail[' . $name . ']', 'type' => ITEM_VALUE_TYPE_UINT64, 'units' => '', 'httptestitemtype' => HTTPSTEP_ITEM_TYPE_LASTSTEP));
foreach ($monitored_items as $item) {
$item_data = DBfetch(DBselect('select i.itemid,i.history,i.trends,i.status,i.delta,i.valuemapid ' . ' from items i, httptestitem hi ' . ' where hi.httptestid=' . $httptestid . ' and hi.itemid=i.itemid ' . ' and hi.type=' . $item['httptestitemtype']));
if (!$item_data) {
$item_data = DBfetch(DBselect('select i.itemid,i.history,i.trends,i.status,i.delta,i.valuemapid ' . ' from items i where i.key_=' . zbx_dbstr($item['key_']) . ' and i.hostid=' . $hostid));
}
$item_args = array('description' => $item['description'], 'key_' => $item['key_'], 'hostid' => $hostid, 'delay' => $delay, 'type' => ITEM_TYPE_HTTPTEST, 'snmp_community' => '', 'snmp_oid' => '', 'value_type' => $item['type'], 'data_type' => ITEM_DATA_TYPE_DECIMAL, 'trapper_hosts' => 'localhost', 'snmp_port' => 161, 'units' => $item['units'], 'multiplier' => 0, 'snmpv3_securityname' => '', 'snmpv3_securitylevel' => 0, 'snmpv3_authpassphrase' => '', 'snmpv3_privpassphrase' => '', 'formula' => 0, 'logtimefmt' => '', 'delay_flex' => '', 'params' => '', 'ipmi_sensor' => '', 'applications' => array($applicationid));
if (!$item_data) {
$item_args['history'] = $history;
$item_args['status'] = ITEM_STATUS_ACTIVE;
$item_args['delta'] = 0;
$item_args['trends'] = $trends;
$item_args['valuemapid'] = 0;
if (!($itemid = add_item($item_args))) {
$result = false;
break;
}
} else {
$itemid = $item_data['itemid'];
$item_args['history'] = $item_data['history'];
$item_args['status'] = $item_data['status'];
$item_args['delta'] = $item_data['delta'];
$item_args['trends'] = $item_data['trends'];
$item_args['valuemapid'] = $item_data['valuemapid'];
if (!update_item($itemid, $item_args)) {
$result = false;
break;
}
}
$httptestitemid = get_dbid('httptestitem', 'httptestitemid');
//.........这里部分代码省略.........
示例11: display_error
$input_error = 1;
display_error(tr('The item name must be entered.'));
set_focus('description');
} elseif (strlen($_POST['NewStockID']) == 0) {
$input_error = 1;
display_error(tr('The item code cannot be empty'));
set_focus('NewStockID');
} elseif (strstr($_POST['NewStockID'], " ") || strstr($_POST['NewStockID'], "'") || strstr($_POST['NewStockID'], "+") || strstr($_POST['NewStockID'], "\"") || strstr($_POST['NewStockID'], "&")) {
$input_error = 1;
display_error(tr('The item code cannot contain any of the following characters - & + OR a space OR quotes'));
set_focus('NewStockID');
}
if ($input_error != 1) {
if (!isset($_POST['New'])) {
/*so its an existing one */
update_item($_POST['NewStockID'], $_POST['description'], $_POST['long_description'], $_POST['category_id'], $_POST['tax_type_id'], $_POST['sales_account'], $_POST['inventory_account'], $_POST['cogs_account'], $_POST['adjustment_account'], $_POST['assembly_account'], $_POST['dimension_id'], $_POST['dimension2_id'], $_POST['selling'], $_POST['depending'], $_POST['barcode'], $_POST['weight'], $blob, $_POST['units']);
} else {
//it is a NEW part
add_item($_POST['NewStockID'], $_POST['description'], $_POST['long_description'], $_POST['category_id'], $_POST['tax_type_id'], $_POST['units'], $_POST['mb_flag'], $_POST['sales_account'], $_POST['inventory_account'], $_POST['cogs_account'], $_POST['adjustment_account'], $_POST['assembly_account'], $_POST['dimension_id'], $_POST['dimension2_id'], $_POST['selling'], $_POST['depending'], $_POST['barcode'], $_POST['weight'], $blob);
}
meta_forward($_SERVER['PHP_SELF']);
}
}
function can_delete($stock_id)
{
$sql = "SELECT COUNT(*) FROM stock_moves " . "WHERE stock_id='{$stock_id}'";
$result = db_query($sql, "could not query stock moves");
$myrow = db_fetch_row($result);
if ($myrow[0] > 0) {
display_error(tr('Cannot delete this item because there are stock ' . 'movements that refer to this item.'));
return false;
示例12: _testChangeIdentifierAndCollection
/**
* Check simultaneous change of identifier and collection of the item.
*/
protected function _testChangeIdentifierAndCollection()
{
$elementSetName = 'Dublin Core';
$elementName = 'Identifier';
// Create a new collection.
$this->collection = insert_collection(array('public' => true));
// Need to release item and to reload it.
$itemId = $this->item->id;
release_object($this->item);
$this->item = get_record_by_id('Item', $itemId);
// Update item.
update_item($this->item, array('collection_id' => $this->collection->id, 'overwriteElementTexts' => true), array($elementSetName => array($elementName => array(array('text' => 'my_new_item_identifier', 'html' => false)))));
$files = $this->item->getFiles();
foreach ($files as $key => $file) {
$this->_checkFile($file);
}
}
示例13: switch
$action = 'show_add_item';
}
}
// Add or update cart as needed
switch ($action) {
case 'add':
$product_key = filter_input(INPUT_POST, 'productkey');
$item_qty = filter_input(INPUT_POST, 'itemqty');
add_item($product_key, $item_qty);
include 'cart_view.php';
break;
case 'update':
$new_qty_list = filter_input(INPUT_POST, 'newqty', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
foreach ($new_qty_list as $key => $qty) {
if ($_SESSION['cart12'][$key]['qty'] != $qty) {
update_item($key, $qty);
}
}
include 'cart_view.php';
break;
case 'show_cart':
include 'cart_view.php';
break;
case 'show_add_item':
include 'add_item_view.php';
break;
case 'empty_cart':
unset($_SESSION['cart12']);
include 'cart_view.php';
break;
case 'end_session':
示例14: update
/**
* Update item
*
* @param array $items
* @return boolean
*/
public static function update($items)
{
$items = zbx_toArray($items);
$itemids = zbx_objectValues($items, 'itemid');
try {
self::BeginTransaction(__METHOD__);
$options = array('itemids' => $itemids, 'editable' => 1, 'webitems' => 1, 'extendoutput' => 1, 'preservekeys' => 1);
$upd_items = self::get($options);
foreach ($items as $gnum => $item) {
if (!isset($upd_items[$item['itemid']])) {
self::exception(ZBX_API_ERROR_PERMISSIONS, S_NO_PERMISSIONS);
}
}
foreach ($items as $inum => $item) {
$item_db_fields = $upd_items[$item['itemid']];
unset($item_db_fields['lastvalue']);
unset($item_db_fields['prevvalue']);
unset($item_db_fields['lastclock']);
unset($item_db_fields['prevorgvalue']);
unset($item_db_fields['lastns']);
if (!check_db_fields($item_db_fields, $item)) {
self::exception(ZBX_API_ERROR_PARAMETERS, 'Incorrect parameters used for Item');
}
$result = update_item($item['itemid'], $item);
if (!$result) {
self::exception(ZBX_API_ERROR_PARAMETERS, 'Cannot update item');
}
}
self::EndTransaction(true, __METHOD__);
return array('itemids' => $itemids);
} catch (APIException $e) {
self::EndTransaction(false, __METHOD__);
$error = $e->getErrors();
$error = reset($error);
self::setError(__METHOD__, $e->getCode(), $error);
return false;
}
}
示例15: _processForm
/**
* Handle the POST for adding an item via the public form.
*
* Validate and save the contribution to the database. Save the ID of the
* new item to the session. Redirect to the consent form.
*
* If validation fails, render the Contribution form again with errors.
*
* @param array $post POST array
* @return bool
*/
protected function _processForm($post)
{
if (!empty($post)) {
//for the "Simple" configuration, look for the user if exists by email. Log them in.
//If not, create the user and log them in.
$user = current_user();
$simple = get_option('contribution_simple');
if (!$user && $simple) {
$user = $this->_helper->db->getTable('User')->findByEmail($post['contribution_simple_email']);
}
// if still not a user, need to create one based on the email address
if (!$user) {
$user = $this->_createNewGuestUser($post);
if ($user->hasErrors()) {
$errors = $user->getErrors()->get();
//since we're creating the user behind the scenes, skip username and name errors
unset($errors['name']);
unset($errors['username']);
foreach ($errors as $error) {
$this->_helper->flashMessenger($error, 'error');
}
return false;
}
}
// The final form submit was not pressed.
if (!isset($post['form-submit'])) {
return false;
}
if (!$this->_validateContribution($post)) {
return false;
}
$contributionTypeId = trim($post['contribution_type']);
if ($contributionTypeId !== "" && is_numeric($contributionTypeId)) {
$contributionType = get_db()->getTable('ContributionType')->find($contributionTypeId);
$itemTypeId = $contributionType->getItemType()->id;
} else {
$this->_helper->flashMessenger(__('You must select a type for your contribution.'), 'error');
return false;
}
$itemMetadata = array('public' => false, 'featured' => false, 'item_type_id' => $itemTypeId);
$collectionId = get_option('contribution_collection_id');
if (!empty($collectionId) && is_numeric($collectionId)) {
$itemMetadata['collection_id'] = (int) $collectionId;
}
$fileMetadata = $this->_processFileUpload($contributionType);
// This is a hack to allow the file upload job to succeed
// even with the synchronous job dispatcher.
if ($acl = get_acl()) {
$acl->allow(null, 'Items', 'showNotPublic');
$acl->allow(null, 'Collections', 'showNotPublic');
}
try {
//in case we're doing Simple, create and save the Item so the owner is set, then update with the data
$item = new Item();
$item->setOwner($user);
$item->save();
$item = update_item($item, $itemMetadata, array(), $fileMetadata);
} catch (Omeka_Validator_Exception $e) {
$this->flashValidatonErrors($e);
return false;
} catch (Omeka_File_Ingest_InvalidException $e) {
// Copying this cruddy hack
if (strstr($e->getMessage(), "'contributed_file'")) {
$this->_helper->flashMessenger("You must upload a file when making a {$contributionType->display_name} contribution.", 'error');
} else {
$this->_helper->flashMessenger($e->getMessage());
}
return false;
} catch (Exception $e) {
$this->_helper->flashMessenger($e->getMessage());
return false;
}
$this->_addElementTextsToItem($item, $post['Elements']);
// Allow plugins to deal with the inputs they may have added to the form.
fire_plugin_hook('contribution_save_form', array('contributionType' => $contributionType, 'record' => $item, 'post' => $post));
$item->save();
//if not simple and the profile doesn't process, send back false for the error
$this->_processUserProfile($post, $user);
$this->_linkItemToContributedItem($item, $contributor, $post);
$this->_sendEmailNotifications($user, $item);
return true;
}
return false;
}