本文整理汇总了PHP中Item::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP Item::delete方法的具体用法?PHP Item::delete怎么用?PHP Item::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Item
的用法示例。
在下文中一共展示了Item::delete方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDelete
public function getDelete(Item $task)
{
if ($task->onwer_id == Auth::user()->id) {
$task->delete();
}
return Redirect::route('home');
}
示例2: testDeleteEnd
function testDeleteEnd()
{
$Item = new Item();
$Item->delete(5);
$results = $Item->find('all');
$expected = array(array('Item' => array('id' => 1, 'name' => 'Item A', 'order' => 0)), array('Item' => array('id' => 2, 'name' => 'Item B', 'order' => 1)), array('Item' => array('id' => 3, 'name' => 'Item C', 'order' => 2)), array('Item' => array('id' => 4, 'name' => 'Item D', 'order' => 3)));
$this->assertEqual($results, $expected);
}
示例3: Item
function item_delete()
{
$item = new Item();
$item->where('id', $this->post('id'));
$item->get();
$item->delete();
$message = array('id' => $this->post('id'), 'message' => 'DELETED!');
$this->response($message, 200);
// 200 being the HTTP response code
}
示例4: deleteItems
public function deleteItems($user)
{
Zend_Registry::get('logger')->entering();
Zend_Registry::get('logger')->debug('Load all items by user');
$itemTable = new Item();
$items = $itemTable->fetchAllByUser($user);
foreach ($items as $item) {
Zend_Registry::get('logger')->debug('Delete all tags from item');
$itemTable->deleteTags($item->id);
Zend_Registry::get('logger')->debug('Delete item');
$where = $this->_db->quoteInto('id = ?', $item->id);
$itemTable->delete($where);
}
Zend_Registry::get('logger')->exiting();
}
示例5: testDelete
function testDelete()
{
// Arrange
$collection_name = "Star Wars cards";
$test_collection = new Collection($collection_name);
$test_collection->save();
$test_collection_id = $test_collection->getId();
$name = "Darth Vader Black Border Premier";
$test_item = new Item($name, $test_collection_id);
$test_item->save();
// Act
$test_item->delete();
$collection_items = $test_collection->getItems();
// Assert
$this->assertEquals([], $collection_items);
}
示例6: Item
if ($s_oncology) {
$s_newitem_id = $flot->datastore->s_new_item($s_oncology);
$s_new_page = S_BASE_EXTENSION . "flot-admin/admin/index.php?section=items&oncology={$s_oncology}&item=" . $s_newitem_id . "&action=edit";
$flot->_page_change($s_new_page);
} else {
echo "no page type :(";
}
break;
case 'delete':
# create the new item, then do a page change to be editing it
$s_page_id = $ufUf->s_get_var('item', false);
if ($s_page_id) {
// delete 'physical' copy on disk
$o_item = $flot->datastore->get_item_data($s_page_id);
$Item = new Item($o_item);
$Item->delete();
// remove from datastore
$flot->datastore->_delete_item($s_page_id);
$s_new_page = S_BASE_EXTENSION . "flot-admin/admin/index.php?section=items&oncology=page&action=list";
$flot->_page_change($s_new_page);
}
break;
}
break;
case "elements":
$s_action = $ufUf->s_get_var_from_allowed("action", array("edit", "list", "new", "delete"), "list");
switch ($s_action) {
case 'edit':
$s_element_id = $ufUf->s_get_var('element', false);
# menu items; purge from cache, preview, regenerate, delete
if ($s_element_id) {
示例7: delete_row
protected function delete_row()
{
if (empty($_REQUEST['item'])) {
throw new Exception('No item specified');
}
if (empty($_REQUEST['name'])) {
throw new Exception('No field name specified');
}
$item = new Item($_REQUEST['item']);
$item->delete($_REQUEST['name']);
echo json_encode(array('msg' => 'Removed row', 'code' => 0));
die;
}
示例8: delete
/**
* @see EquipmentInterface::delete()
* @return bool
* @throws EquipmentDeleteItemLinkException
* @throws EquipmentDeleteFailedException
* @throws EquipmentNoInstanceException
*/
public function delete()
{
global $transaction;
if ($this->equipment_id and $this->equipment) {
$transaction_id = $transaction->begin();
try {
parent::delete();
$equipment_is_item = new EquipmentIsItem_Access($this->equipment_id);
if ($equipment_is_item->delete() == false) {
throw new EquipmentDeleteItemLinkException();
}
if ($this->equipment->delete() == false) {
throw new EquipmentDeleteFailedException();
}
} catch (BaseException $e) {
if ($transaction_id != null) {
$transaction->rollback($transaction_id);
}
throw $e;
}
if ($transaction_id != null) {
$transaction->commit($transaction_id);
}
return true;
} else {
throw new EquipmentNoInstanceException();
}
}
示例9: test_get_a_week
public function test_get_a_week()
{
$currentWeek = jdate("W", time(), "", "Asia/Tehran", "en");
$currentYear = jdate("Y");
$twoWeekAgo = strtotime("-2 week");
$weekAgo = strtotime("-1 week");
$current = time() + 30;
// chone ke momkene moghe get kardan state taghir kone man dige inja 30 sanie balatar zadam ke az in jahat moshekl pish nayad!
$twoWeekLater = strtotime("+2 week");
$weekLater = strtotime("+1 week");
$oneHour = 3600;
$tempItem = new Item();
$itemTwoWeekAge = new Item();
$itemTwoWeekAge->create($twoWeekAgo, $twoWeekAgo + $oneHour, "2 hafte gozashte", ITEM_STATE_DONE, 3)->save($this->user, $this->task);
$itemOneWeekAge = new Item();
$itemOneWeekAge->create($weekAgo, $weekAgo + $oneHour, "1 hafte gozashte", ITEM_STATE_UNDONE)->save($this->user, $this->task);
$itemCurrentWeek = new Item();
$itemCurrentWeek->create($current, $current + $oneHour, "hamin hafte", ITEM_STATE_INCOMING)->save($this->user, $this->task);
$itemOneWeekLater = new Item();
$itemOneWeekLater->create($weekLater, $weekLater + $oneHour, "1 hafte bad", ITEM_STATE_UNDONE)->save($this->user, $this->task);
$itemTwoWeekLater = new Item();
$itemTwoWeekLater->create($twoWeekLater, $twoWeekLater + $oneHour, "2 hafte bad", ITEM_STATE_UNDONE)->save($this->user, $this->task);
$this->_assert_true($itemTwoWeekAge->__toString() == $tempItem->getByWeek($currentYear, $currentWeek - 2, $this->user)->__toString());
$this->_assert_true($itemOneWeekAge->__toString() == $tempItem->getByWeek($currentYear, $currentWeek - 1, $this->user)->__toString());
$this->_assert_true($itemCurrentWeek->__toString() == $tempItem->getByWeek($currentYear, $currentWeek, $this->user)->__toString());
$this->_assert_true($itemOneWeekLater->__toString() == $tempItem->getByWeek($currentYear, $currentWeek + 1, $this->user)->__toString());
$this->_assert_true($itemTwoWeekLater->__toString() == $tempItem->getByWeek($currentYear, $currentWeek + 2, $this->user)->__toString());
$itemTwoWeekAge->delete();
$itemOneWeekAge->delete();
$itemCurrentWeek->delete();
$itemOneWeekLater->delete();
$itemTwoWeekLater->delete();
}
示例10: _attachFilesToItem
/**
* Attach a list of files to an item.
*
* @param Item $item
* @param array $fileUrls An array of the urls of files to attach to item.
* @param boolean $itemDelete Delete item (default) or not if the file can't
* be ingested.
* @return boolean True if success, false else.
*/
protected function _attachFilesToItem($item, $fileUrls, $itemDelete = true)
{
// Sometime, fileUrls is a null or an empty string.
if (empty($fileUrls)) {
return true;
}
foreach ($fileUrls as $fileUrl) {
// Set the transfer strategy according to file name.
$parsedFileUrl = parse_url($fileUrl);
if (!isset($parsedFileUrl['scheme']) || $parsedFileUrl['scheme'] == 'file') {
$transferStrategy = 'Filesystem';
$fileUrlOriginal = $fileUrl;
$fileUrl = $parsedFileUrl['path'];
if (!$this->_allowLocalPath($fileUrl)) {
$msg = 'Local paths are not allowed by the administrator (%s) [%s].';
$this->_log($msg, array($fileUrlOriginal, !isset($parsedFileUrl['scheme']) ? 'no scheme' : 'file scheme'), Zend_Log::ERR);
if ($itemDelete) {
$item->delete();
}
release_object($item);
return false;
}
} else {
$transferStrategy = 'Url';
$fileUrl = $this->_rawUrlEncode($fileUrl);
}
// Import the file and attach it to the item.
try {
$files = insert_files_for_item($item, $transferStrategy, $fileUrl, array('ignore_invalid_files' => false));
} catch (Omeka_File_Ingest_InvalidException $e) {
$msg = 'Invalid file URL "%s": %s';
$this->_log($msg, array($fileUrl, $e->getMessage()), Zend_Log::ERR);
if ($itemDelete) {
$item->delete();
}
release_object($item);
return false;
} catch (Omeka_File_Ingest_Exception $e) {
$msg = 'Could not import file "%s": %s';
$this->_log($msg, array($fileUrl, $e->getMessage()), Zend_Log::ERR);
if ($itemDelete) {
$item->delete();
}
release_object($item);
return false;
}
release_object($files);
}
return true;
}
示例11: testDelete
function testDelete()
{
//Arrange
$description = "Pliny the Elder";
$cost = 5.0;
$id = null;
$test_item = new Item($description, $cost, $id);
$test_item->save();
$description2 = "Lagunitas IPA";
$cost2 = 7.0;
$test_item2 = new Item($description2, $cost2, $id);
$test_item2->save();
//Act
$test_item->delete();
$result = Item::getAll();
//Assert
$this->assertEquals($test_item2, $result[0]);
}
示例12: delete
public function delete()
{
if ($this->f3->exists('PARAMS.tok')) {
//getIdByTok
$getIdByTok = new Item($this->db);
$getIdByTok->getIdByTok($this->f3->get('PARAMS.tok'));
$iid = $this->f3->get('ID.id');
// del by ID (not by TOK)
$tags = new Tag2Item($this->db);
$loaderase = $tags->getByItemId($iid);
if (count($loaderase) > 0) {
foreach ($loaderase as $t) {
$itemid = $t['id'];
$deltags = new Tag2Item($this->db);
$deltags->delete($itemid);
}
}
$item = new Item($this->db);
$item->delete($this->f3->get('PARAMS.tok'));
}
$this->f3->set('COOKIE.message', 'The bookmark was deleted');
$this->f3->set('COOKIE.messagetype', 'alert-info hide5s');
$this->f3->reroute('/');
}
示例13: deleteItem
private function deleteItem($id_item = null)
{
if (is_null($id_item)) {
return false;
}
$item = new Item($id_item);
return $item->delete();
}
示例14: destroyAction
public function destroyAction()
{
$this->logger->entering();
$this->logger->info('Loading item from params');
$items = new Item();
$item = $this->_getParam('item');
$this->logger->info("Loading item by id");
$id = $item['id'];
$item = $items->find($id)->current();
$this->logger->info('Ensure owned by user');
if ($this->session->user_id != $item->owner_id) {
$this->logger->warn('User is not item owner');
$this->flash->notice = "Invalid Action";
$this->_redirect('/');
}
$this->logger->info("Delete item by id {$id}");
$where = $this->db->quoteInto('id = ?', $id);
$rows_affected = $items->delete($where);
$this->logger->info('Delete item tag associations');
$items->deleteTags($id);
$this->logger->info("Removing old item from search index");
ItemIndex::delete($item);
$this->logger->info('Redirect to item index');
$this->_redirect('items');
$this->logger->exiting();
}
示例15: Item
function test_uncompleted_after_completed()
{
$item = new Item();
$item->create(time() + 1000, time() + 10000, "this item created for testing goal completed", ITEM_STATE_DONE_WAIT_FOR_FEEDBACK)->save($this->user, $this->task);
$this->goal->create(100, strtotime("-1 week"), strtotime("+1 week"))->save($this->task);
$item->delete();
$this->goal->get($this->goal->getId());
$this->_assert_equals($this->goal->getAchieveTime(), null);
$item->delete();
}