本文整理汇总了PHP中Item::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Item::find方法的具体用法?PHP Item::find怎么用?PHP Item::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Item
的用法示例。
在下文中一共展示了Item::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
public static function store()
{
self::check_logged_in();
// POST-pyynnön muuttujat sijaitsevat $_POST nimisessä assosiaatiolistassa
$params = $_POST;
//array of item_ids (string)
//View::make('notimplemented.html');
$user_id = $_SESSION['user'];
if (!$params) {
//Redirect::to('/outfits/' . $user_id . 'new/', array('message' => 'Please select items!'));
}
$items_in_outfit = array();
foreach ($params as $key => $value) {
if (strlen($key) == 1) {
$items_in_outfit[] = Item::find($value);
} else {
if ($key == 'rating') {
$rating = $value;
} else {
if ($key == 'comment') {
$comment = $value;
}
}
}
}
$outfit_object = new Outfit(array('outfit_id' => null, 'items' => $items_in_outfit, 'rating' => $rating, 'comment' => $comment));
$outfit_object->save_to_db($user_id);
Redirect::to('/outfits/' . $user_id, array('message' => 'Outfit created!'));
}
示例2: output
function output($message = null, $allowHtml = false, $addslashes = false)
{
$message = preg_replace('/\\%name\\%/', $this->Session->read('Game.Character.name'), $message);
$message = preg_replace('/\\%class\\%/', $this->Session->read('Game.Type.name'), $message);
$message = preg_replace('/\\%hisher\\%/', 'his', $message);
if ($allowHtml != true) {
$message = htmlspecialchars($message);
}
/* Items */
preg_match_all('/\\[item\\](.*?)\\[\\/item\\]/', $message, $items);
if (isset($items[1]) && !empty($items[1])) {
// Laat de makers het niet zien...
App::import('Model', 'Item');
$Item = new Item();
$Item->contain();
$items = $Item->find('all', array('fields' => array('Item.id', 'Item.name', 'Item.quality'), 'conditions' => array('Item.name' => $items[1])));
foreach ($items as $item) {
$message = str_replace('[item]' . $item['Item']['name'] . '[/item]', '<span class="item_' . $item['Item']['quality'] . '" onmouseover="showMouseInfo(url + \'items/view/' . addslashes($item['Item']['name']) . '\');" onmouseout="hideMouseInfo();">[' . addslashes($item['Item']['name']) . ']</span>', $message);
}
}
// Quests
preg_match_all('/\\[quest\\](.*?)\\[\\/quest\\]/', $message, $quests);
if (isset($quests[1]) && !empty($quests[1])) {
foreach ($quests[1] as $quest) {
$message = str_replace('[quest]' . $quest . '[/quest]', '<span class="quest" onmouseover="showMouseInfo(url + \'quests/view/' . $quest . '\');" onmouseout="hideMouseInfo();">' . htmlspecialchars($quest) . '</span>', $message);
}
}
if ($addslashes === true) {
$message = addslashes($message);
}
return $message;
}
示例3: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
$item = Item::find($id);
if (!$item) {
return false;
}
$item->delete();
}
示例4: testShouldDeleteAllCorrectly
public function testShouldDeleteAllCorrectly()
{
$this->Item->deleteAll(['Item.id' => [1, 3]]);
$this->assertEmpty($this->Item->find('all'));
$this->Item->includeDeletedRecords();
$item = $this->Item->read(null, 1);
$this->assertEqual($item['Item']['description'], ItemFixture::DESCR_DELETED);
}
示例5: postUpdate
public function postUpdate()
{
$newname = Input::get('name');
$id = Input::get('id');
$ini = Item::find($id);
$ini->name = $newname;
$ini->save();
return Redirect::route('home');
}
示例6: mostrarInfoProducto
public function mostrarInfoProducto($url)
{
$lang = Idioma::where('codigo', App::getLocale())->where('estado', 'A')->first();
$item_lang = Item::join('item_lang', 'item_lang.item_id', '=', 'item.id')->where('item_lang.lang_id', $lang->id)->where('item_lang.url', $url)->first();
//Me quedo con el item, buscando por url
//$item = Item::where('url', $url)->first();
$item = Item::find($item_lang->item_id);
$this->array_view['item'] = $item;
return View::make($this->folder_name . '.' . $this->project_name . '-ver', $this->array_view);
}
示例7: delete_items
function delete_items($id = FALSE)
{
$item = Item::find($id);
$item->inactive = 1;
$item->save();
if (!$item) {
$this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_delete_item_error'));
} else {
$this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_delete_item_success'));
}
redirect('items');
}
示例8: vistaEditar
public function vistaEditar($id)
{
//Me quedo con el item, buscando por id
$item = Item::find($id);
if ($item) {
$this->array_view['item'] = $item;
return View::make($this->folder_name . '.editar-item', $this->array_view);
} else {
$this->array_view['texto'] = Lang::get('controllers.error_carga_pagina');
return View::make($this->project_name . '-error', $this->array_view);
}
}
示例9: ordenar
public function ordenar()
{
foreach (Input::get('orden') as $key => $imagen_id) {
if ($key == 0) {
$destacado = 'A';
} else {
$destacado = NULL;
}
$respuesta = Imagen::ordenarImagenItem($imagen_id, $key, Input::get('item_id'), $destacado);
}
$item = Item::find(Input::get('item_id'));
$menu = $item->seccionItem()->menuSeccion()->modulo()->nombre;
return Redirect::to('/' . $menu . '/' . $item->lang()->url)->with('mensaje', $respuesta['mensaje'])->with('ok', true);
}
示例10: test_find
function test_find()
{
//Arrange
$name = "Hello Kitty";
$name2 = "Pokemon";
$test_Item = new Item($name);
$test_Item->save();
$test_Item2 = new Item($name2);
$test_Item2->save();
//Act
$result = Item::find($test_Item2->getId());
//Assert
$this->assertEquals($test_Item2, $result);
}
示例11: run
public function run()
{
$items = Item::all();
foreach ($items as $item) {
$i = Item::find($item->id);
if ($item->participant) {
$i->event_id = $item->participant->event_id;
$i->save();
}
if ($item->member) {
$i->team_id = $item->member->team_id;
$i->save();
}
}
}
示例12: update
public static function update($id)
{
self::check_logged_in();
$params = $_POST;
$attributes = array('id' => $id, 'itemtype_id' => Item::find($id)->itemtype_id, 'description' => $params['description']);
$item = new Item($attributes);
$errors = $item->errors();
if (count($errors) > 0) {
$item = Item::find($id);
$itemtype = ItemType::find($item->itemtype_id);
View::make('item/edit.html', array('errors' => $errors, 'given_description' => $params['description'], 'item' => $item, 'itemtype' => $itemtype));
} else {
$item->update();
Redirect::to('/item/' . $item->id, array('message' => 'The item has been modified successfully!'));
}
}
示例13: loot
/**
* Looting an Item from an Obstacle in the game map
*
* @param int the id of the character
* @param int the id of the areas_obstacles_item
*/
function loot($characterInfo = null, $areas_obstacles_item_id = null)
{
if ($this->canLoot($areas_obstacles_item_id, $characterInfo['id'], $characterInfo['area_id'])) {
// Opslaan die handel
App::import('Model', 'AreasObstaclesItem');
$AreasObstaclesItem = new AreasObstaclesItem();
$drop = $AreasObstaclesItem->find('first', array('conditions' => array('AreasObstaclesItem.id' => $areas_obstacles_item_id)));
$data['Drop']['areas_obstacle_item_id'] = $drop['AreasObstaclesItem']['id'];
$data['Drop']['item_id'] = $drop['AreasObstaclesItem']['item_id'];
$data['Drop']['character_id'] = $characterInfo['id'];
$dataInventory['Inventory']['item_id'] = $drop['AreasObstaclesItem']['item_id'];
$dataInventory['Inventory']['character_id'] = $characterInfo['id'];
if ($this->save($data)) {
// Item opvragen, en eventueel de character_id invullen als deze character de eerste is...
App::import('Model', 'Item');
$Item = new Item();
$Item->unbindModelAll();
$thisItem = $Item->find('first', array('conditions' => array('Item.id' => $drop['AreasObstaclesItem']['item_id'])));
if (isset($thisItem['Item']['character_id']) && $thisItem['Item']['character_id'] == 0) {
$thisItem['Item']['character_id'] = $characterInfo['id'];
$thisItem['Item']['discovered'] = date('Y-m-d H:i:s');
$Item->save($thisItem);
}
App::import('Model', 'Inventory');
$Inventory = new Inventory();
// Bagid en index opvragen
$bagIndex = $this->hasFreeSpace($characterInfo['id'], $drop['AreasObstaclesItem']['item_id'], true);
$dataInventory['Inventory']['index'] = $bagIndex['index'];
$dataInventory['Inventory']['bag_id'] = $bagIndex['bag_id'];
// Save to inventory
if ($Inventory->save($dataInventory)) {
App::import('Model', 'Quest');
$Quest = new Quest();
$Quest->update(null, $characterInfo['id']);
// Item is nu in de inventory... We kunnen eventueel questen updaten nu
return true;
} else {
return false;
}
} else {
return false;
}
} else {
return false;
}
}
示例14: vistaEditar
public function vistaEditar($id, $next, $seccion_next)
{
//Me quedo con el item, buscando por id
$item = Item::find($id);
$portfolio = Portfolio::find($item->portfolio()->id);
$secciones = parent::seccionesDinamicas();
if ($portfolio) {
$this->array_view['item'] = $portfolio->item();
$this->array_view['portfolio'] = $portfolio;
$this->array_view['secciones'] = $secciones;
$this->array_view['continue'] = $next;
$this->array_view['seccion_next'] = $seccion_next;
return View::make($this->folder_name . '.editar', $this->array_view);
} else {
$this->array_view['texto'] = Lang::get('controllers.error_carga_pagina');
return View::make($this->project_name . '-error', $this->array_view);
}
}
示例15: SupplierAndItemInfo
public function SupplierAndItemInfo()
{
App::uses("Supplier", "Inventory.Model");
App::import("Model", "Inventory.Item");
$supplierModel = new Supplier();
$itemModel = new Item();
$supplierModel->recursive = 0;
$suppliers = $supplierModel->find("all");
$tmp_suplliers = array();
foreach ($suppliers as $key => $supplier) {
$tmp_suplliers[$supplier['Supplier']['id']]['name'] = $supplier['Supplier']['name'];
$tmp_suplliers[$supplier['Supplier']['id']]['email'] = $supplier['Supplier']['email'];
$tmp_suplliers[$supplier['Supplier']['id']]['gst'] = $supplier['Supplier']['gst_rate'];
$tmp_suplliers[$supplier['Supplier']['id']]['pst'] = $supplier['Supplier']['pst_rate'];
$tmp_suplliers[$supplier['Supplier']['id']]['item'] = $itemModel->find("list", array("fields" => array("id_plus_item"), 'conditions' => array('supplier_id' => $supplier['Supplier']['id'])));
$tmp_suplliers[$supplier['Supplier']['id']]['address'] = $this->address_format($supplier['Supplier']['address'], $supplier['Supplier']['city'], $supplier['Supplier']['province'], $supplier['Supplier']['country'], $supplier['Supplier']['postal_code']);
$tmp_suplliers[$supplier['Supplier']['id']]['phone'] = $this->phone_format($supplier['Supplier']['phone'], $supplier['Supplier']['phone_ext'], $supplier['Supplier']['cell'], $supplier['Supplier']['fax_number']);
}
return $tmp_suplliers;
}