当前位置: 首页>>代码示例>>PHP>>正文


PHP Inventory::save方法代码示例

本文整理汇总了PHP中Inventory::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Inventory::save方法的具体用法?PHP Inventory::save怎么用?PHP Inventory::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Inventory的用法示例。


在下文中一共展示了Inventory::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Inventory

 function test_find()
 {
     $item = "POGs";
     $item2 = "Pokemon Cards";
     $test_item = new Inventory($item);
     $test_item->save();
     $test_item2 = new Inventory($item2);
     $test_item2->save();
     $search_item = $test_item->getItem();
     $result = Inventory::find($search_item);
     $this->assertEquals($test_item, $result);
 }
开发者ID:CaseyH33,项目名称:Inventory-MySQL,代码行数:12,代码来源:InventoryTest.php

示例2: Inventory

 function test_find()
 {
     $description = "Blue candy";
     $description2 = "Light blue candy";
     $test_Inventory = new Inventory($description);
     $test_Inventory->save();
     $test_Inventory2 = new Inventory($description2);
     //Act
     $id = $test_Inventory->getId();
     $result = Inventory::find($id);
     //Assert
     $this->assertEquals($test_Inventory, $result);
 }
开发者ID:kylepratuch,项目名称:Inventory,代码行数:13,代码来源:InventoryTest.php

示例3: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Inventory();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Inventory'])) {
         $model->attributes = $_POST['Inventory'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:griffindor,项目名称:own-inventory,代码行数:17,代码来源:InventoryController.php

示例4: actionCreate

 public function actionCreate()
 {
     $model = new Inventory();
     if (isset($_POST['Inventory'])) {
         $model->setAttributes($_POST['Inventory']);
         if ($model->save()) {
             if (Yii::app()->getRequest()->getIsAjaxRequest()) {
                 Yii::app()->end();
             } else {
                 $this->redirect(array('view', 'id' => $model->inventory_id));
             }
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:schmunk42,项目名称:yii-sakila-crud,代码行数:15,代码来源:InventoryController.php

示例5: Inventory

 function test_find()
 {
     //Arrange
     $item = "Antique Toothpick Holders";
     $item2 = "Ornamental Mouse Traps";
     $test_Inventory = new Inventory($item);
     $test_Inventory->save();
     $test_Inventory2 = new Inventory($item2);
     $test_Inventory2->save();
     //Act
     $id = $test_Inventory->getId();
     $result = Inventory::find($id);
     //Assert
     $this->assertEquals($test_Inventory, $result);
 }
开发者ID:alexdbrown,项目名称:sql-inventory,代码行数:15,代码来源:InventoryTest.php

示例6: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     if (Input::hasFile('image')) {
         $inventory = new Inventory();
         $inventory->title = Input::get('title');
         $inventory->description = Input::get('description');
         $inventory->users_id = Input::get('users_id');
         $inventory->collection_id = Input::get('collection');
         $md5 = md5_file(Input::file('image'));
         if (Input::file('image')->move(public_path() . '/uploads/', $md5)) {
             $inventory->file_name = $md5;
             $inventory->save();
         }
         return Redirect::route('inventory.index');
     }
 }
开发者ID:joisak,项目名称:phorrow,代码行数:21,代码来源:InventoryController.php

示例7: Inventory

 function remove_item()
 {
     $invoice_id = $this->input->post("invoice_id");
     $inventory_id = $this->input->post("inventory_id");
     $inventoryObject = new Inventory($inventory_id);
     $inventoryObject->invoice_id = NULL;
     $inventoryObject->status = 1;
     // In Stock
     $inventoryObject->save();
     $invoiceObject = new Invoice($invoice_id);
     $invoiceObject->total -= $inventoryObject->sale_price;
     $invoiceObject->save();
     $data["total"] = $invoiceObject->total;
     $data["tbody_html"] = $this->_html($invoiceObject);
     echo json_encode($data);
 }
开发者ID:narendranag,项目名称:Profectus,代码行数:16,代码来源:invoicing.php

示例8: 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;
     }
 }
开发者ID:MortalROs,项目名称:Naxasius-Game-Engine,代码行数:52,代码来源:drop.php

示例9: add_item

 public function add_item($item_id, $item_owner, $amount)
 {
     $criteria = new CDbCriteria();
     $criteria->select = 'MAX(item_unique_id) as item_unique_id';
     $last_item_id = Inventory::model()->find($criteria);
     $form = new Inventory();
     $form->scenario = 'buy';
     $form->item_id = $item_id;
     $form->item_owner = $item_owner;
     $form->item_creator = '';
     $form->item_count = $amount;
     $form->item_unique_id = $last_item_id->item_unique_id + 1;
     $form->item_location = 127;
     $form->item_skin = $item_id;
     $form->save(false);
     return $form->item_unique_id;
 }
开发者ID:noiary,项目名称:Aion-Core-v4.7.5,代码行数:17,代码来源:MailController.php

示例10: Set_Player_Inventory

 public function Set_Player_Inventory($db_id, $input)
 {
     if (Cache::has($this->class_name . "_" . $db_id . "_Inventory_MD5")) {
         //check the input MD5 against this
         if (md5($input) == Cache::get($this->class_name . "_" . $db_id . "_Inventory_MD5")) {
             return true;
         }
     } else {
         //If we have gotten to this point than we either don't have a cache on file or the data is not the same so update/insert and build cache
         $last_inventory_update = Inventory::where(function ($query) use($db_id) {
             $query->where('db_id', '=', $db_id);
             $query->where(DB::raw('DATE(updated_at)'), '=', $this->date_only);
         })->order_by('id', 'desc')->first('id');
         try {
             if ($last_inventory_update) {
                 $query_update_inv = "UPDATE `inventories` SET `inventory` = ?, updated_at = ? WHERE `id` = ?";
                 $bindings_update_inventory = array(gzcompress(json_encode($input), 5), $this->date, $last_inventory_update->id);
                 if (DB::query($query_update_inv, $bindings_update_inventory) === false) {
                     throw new Exception('Error updating inventory.');
                 }
             } else {
                 $inv = new Inventory();
                 $inv->db_id = $db_id;
                 $inv->inventory = gzcompress(json_encode($input), 5);
                 if (!$inv->save()) {
                     throw new Exception('Add inventory query failed:');
                 }
             }
         } catch (Exception $e) {
             Log::info($log_header . $e->getMessage());
             file_put_contents($this->logpath . $this->logdate . '_bad_player.json', json_encode($input));
             return false;
         }
     }
     //set cache file and cache MD5 file
     Cache::forever($this->class_name . "_" . $db_id . "_Inventory", json_encode($input));
     Cache::forever($this->class_name . "_" . $db_id . "_Inventory_MD5", md5($input));
     return true;
 }
开发者ID:odie5533,项目名称:ThumpDumpDB,代码行数:39,代码来源:PlayerAPIController.php

示例11: trim

    $cpucurrent = trim(base64_decode($_REQUEST["cpucurrent"]));
    $cpumax = trim(base64_decode($_REQUEST["cpumax"]));
    $mem = trim(base64_decode($_REQUEST["mem"]));
    $hdinfo = trim(base64_decode($_REQUEST["hdinfo"]));
    if ($hdinfo != null) {
        $arHd = explode(",", $hdinfo);
        $hdmodel = trim(str_replace("Model=", "", trim($arHd[0])));
        $hdfirmware = trim(str_replace("FwRev=", "", trim($arHd[1])));
        $hdserial = trim(str_replace("SerialNo=", "", trim($arHd[2])));
    } else {
        $hdmodel = '';
        $hdfirmware = '';
        $hdserial = '';
    }
    $caseman = trim(base64_decode($_REQUEST["caseman"]));
    $casever = trim(base64_decode($_REQUEST["casever"]));
    $caseserial = trim(base64_decode($_REQUEST["caseserial"]));
    $casesasset = trim(base64_decode($_REQUEST["casesasset"]));
    if (!$Inventory || !$Inventory->isValid()) {
        $Inventory = new Inventory(array('hostID' => $Host->get('id'), 'sysman' => $sysman, 'sysproduct' => $sysproduct, 'sysversion' => $sysversion, 'sysserial' => $sysserial, 'systype' => $systype, 'biosversion' => $biosversion, 'mbman' => $mbman, 'mbproductname' => $mbproductname, 'mbversion' => $mbversion, 'mbserial' => $mbserial, 'mbasset' => $mbasset, 'cpuman' => $cpuman, 'cpuversion' => $cpuversion, 'cpucurrent' => $cpucurrent, 'cpumax' => $cpumax, 'mem' => $mem, 'hdmodel' => $hdmodel, 'hdfirmware' => $hdfirmware, 'hdserial' => $hdserial, 'caseman' => $caseman, 'casever' => $casever, 'caseserial' => $caseserial, 'caseasset' => $casesasset));
    } else {
        $Inventory->set('sysman', $sysman)->set('sysproduct', $sysproduct)->set('sysversion', $sysversion)->set('sysserial', $sysserial)->set('systype', $systype)->set('biosversion', $biosversion)->set('biosvendor', $biosvendor)->set('biosdate', $biosdate)->set('mbman', $mbman)->set('mbproductname', $mbproductname)->set('mbversion', $mbversion)->set('mbserial', $mbserial)->set('mbasset', $mbasset)->set('cpuman', $cpuman)->set('cpuversion', $cpuversion)->set('cpucurrent', $cpucurrent)->set('cpumax', $cpumax)->set('mem', $mem)->set('hdmodel', $hdmodel)->set('hdfirmware', $hdfirmware)->set('hdserial', $hdserial)->set('caseman', $caseman)->set('casever', $casever)->set('caseserial', $caseserial)->set('caseasset', $casesasset);
    }
    if ($Inventory->save()) {
        print _('Done');
    } else {
        throw new Exception(_('Failed to create inventory for this host!'));
    }
} catch (Exception $e) {
    print $e->getMessage();
}
开发者ID:bramverstraten,项目名称:fogproject,代码行数:31,代码来源:inventory.php

示例12: parseFile


//.........这里部分代码省略.........
                                } else {
                                    if ($it->action == "d") {
                                        $inv->quantity -= $it->quantity;
                                    } else {
                                        if ($it->action == "a") {
                                            $inv->quantity = $it->quantity;
                                        }
                                    }
                                }
                            } else {
                                if ($field == "item-note") {
                                    $it->note = $record[$key];
                                } else {
                                    if ($field == "will-ship-internationally") {
                                        $it->will_ship = $record[$key];
                                    } else {
                                        if ($field == "product-id") {
                                            $it->isbn = $record[$key];
                                        } else {
                                            if ($field == "upc") {
                                                $it->upc = $record[$key];
                                            } else {
                                                if ($field == "price") {
                                                    $it->price = $record[$key];
                                                } else {
                                                    if ($field == "expedited-shipping") {
                                                        $it->expedited_shipping = $record[$key];
                                                    } else {
                                                        if ($field == "item-condition") {
                                                            $it->condition = $record[$key];
                                                        } else {
                                                            if ($field == "image-url") {
                                                                $it->image_url = $record[$key];
                                                            } else {
                                                                if ($field == "browse-path") {
                                                                    $it->browse_path = $record[$key];
                                                                } else {
                                                                    if ($field == "fulfillment-center-id") {
                                                                        $it->fulfillment_center_id = $record[$key];
                                                                    } else {
                                                                        if ($field == "location") {
                                                                            $it->location = $record[$key];
                                                                        } else {
                                                                            if ($field == "author") {
                                                                                $it->author = $record[$key];
                                                                            } else {
                                                                                if ($field == "publisher") {
                                                                                    $it->publisher = $record[$key];
                                                                                } else {
                                                                                    if ($field == "condition-id") {
                                                                                        $it->condition_id = $record[$key];
                                                                                        $inv->condition = $arrConditionValues[$it->condition_id];
                                                                                    } else {
                                                                                        if ($field == "cost") {
                                                                                            $it->cost = $record[$key];
                                                                                        } else {
                                                                                            if ($field == "source") {
                                                                                                $it->source = $record[$key];
                                                                                            } else {
                                                                                                if ($field == "open_date") {
                                                                                                    $it->open_date = $record[$key];
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        $inv->isbn = $it->isbn;
        $inv->price = $it->price;
        $inv->image = $it->image_url;
        $inv->location = $it->location;
        $inv->author = $it->author;
        $inv->publisher = $it->publisher;
        $inv->cost = $it->cost;
        $inv->name = $it->name;
        $inv->description = $it->description;
        $inv->dirty = 1;
        //$inv->shopify_id = 0;
        $inv->save();
        $it->save();
    }
    return true;
}
开发者ID:Alex--Jin,项目名称:shopify_private_fillz,代码行数:101,代码来源:itparser.php

示例13: PDO

<?php

require_once __DIR__ . "/../vendor/autoload.php";
require_once __DIR__ . "/../src/Inventory.php";
$app = new Silex\Application();
$server = 'mysql:host=localhost;dbname=inventory';
$username = 'root';
$password = 'root';
$DB = new PDO($server, $username, $password);
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views'));
$app->get("/", function () use($app) {
    return $app['twig']->render('index.html.twig', array('candies' => Inventory::getAll()));
});
$app->get("/candies", function () use($app) {
    return $app['twig']->render('candies.html.twig', array('candies' => Inventory::getAll()));
});
$app->post("/candies", function () use($app) {
    $candy = new Inventory($_POST['name']);
    $candy->save();
    return $app['twig']->render('candies.html.twig', array('candies' => Inventory::getAll()));
});
$app->post("/delete_candy", function () use($app) {
    Inventory::deleteAll();
    return $app['twig']->render('index.html.twig');
});
$app->get("/found_candy", function () use($app) {
    return $app['twig']->render('found_candy.html.twig', array('candies' => Inventory::find($_GET['search'])));
});
return $app;
开发者ID:kylepratuch,项目名称:Inventory,代码行数:29,代码来源:app.php

示例14: actionAccountActivation

 /**
  * Activa una cuenta
  */
 public function actionAccountActivation()
 {
     //Initi
     $template = 'error';
     $data = array('message' => '', 'code' => 'en la activación.');
     //Validation input
     /*
     $user = new Users();
     $user->attributes = array(
     	'email'=>$_GET['email']				
     );
     */
     //Check email
     $validator = new CEmailValidator();
     if ($validator->validateValue($_GET['email'])) {
         //Check if user exist
         $user = Users::model()->find('email=:email', array(':email' => $_GET['email']));
         if ($user) {
             //User found
             if ($user->status == Users::STATUS_PENDING_ACTIVATION) {
                 //Load his knight
                 $knight = Knights::model()->find('users_id=:users_id', array('users_id' => $user->id));
                 //Check if code is the same
                 $codigo_activacion = md5($user->email . $knight->name . $user->password_md5 . $user->suscribe_date);
                 if ($_GET['code'] === $codigo_activacion) {
                     //ACTIVATED ACCOUNT
                     //1.- change status
                     $user->status = Users::STATUS_ENABLE;
                     $user->save();
                     $knight->status = Knights::STATUS_WITHOUT_EQUIPMENT;
                     $knight->save();
                     //2.- create card
                     $knight_card = new KnightsCard();
                     $knight_card->attributes = array('knights_id' => $knight->id);
                     $knight_card->save();
                     //3.- Create general stats
                     $knight_stats = new KnightsStats();
                     $knight_stats->attributes = array('knights_id' => $knight->id);
                     if (!$knight_stats->save()) {
                         Yii::trace('[Site][actionAccountActivation] No se puede salvar las stats del caballero', 'error');
                     }
                     //4.- set stats attack location
                     //load all location
                     /*
                     $locations = Constants::model()->findAll( 
                     	'type=:type',
                     	array( ':type'=> Constants::KNIGHTS_LOCATION)
                     );
                     
                     if( count($locations) > 0 ){
                     	//Foreach location set a value for attack location. Defense is depending of shield
                     	foreach( $locations as $location ){
                     		$knights_stats_attack_location = new KnightsStatsAttackLocation();
                     		$knights_stats_attack_location->attributes = array(
                     			'knights_id'=>$knight->id,
                     			'location'=>$location['id']
                     		);
                     		$knights_stats_attack_location->save();
                     	}
                     	
                     }else{
                     	$data['message'] .= 'No hay datos de localizaciones';
                     }
                     */
                     //Change for points of location. 48 is the maximun position number in the attack and defense points
                     for ($i = 1; $i <= 48; $i++) {
                         $knights_stats_attack_location = new KnightsStatsAttackLocation();
                         $knights_stats_attack_location->attributes = array('knights_id' => $knight->id, 'location' => $i);
                         $knights_stats_attack_location->save();
                     }
                     //6.- Set default equipment
                     //Set armours
                     foreach (Armours::getDefaultEquipment() as $key => $id) {
                         //Find armour
                         $armour = Armours::model()->findByPk($id);
                         if ($armour) {
                             //creamos nuevo objeto de la armadura
                             $armour_object = new ArmoursObjects();
                             $armour_object->attributes = array('armours_id' => $id, 'knights_id' => $knight->id, 'current_pde' => $armour->pde);
                             if (!$armour_object->save()) {
                                 //$data['message'] .= '<p>Armadura '.$id.' ('.$armour_object->attributes['armours_id'].') generada ('.var_dump( $armour_object->getErrors()).') ';
                                 Yii::trace('[SITE][actionAccountActivation] Error al salvar la armadura ' . $armour->name, 'error');
                             }
                             //Lo inventariamos. Como son los primeros objetos la posición que ocupa será empezando desde 1
                             $inventory = new Inventory();
                             //Sabemos que no hay objetos por lo que ocupamos las primeras posiciones, que concuerdan con el id
                             $inventory->attributes = array('knights_id' => $knight->id, 'type' => Inventory::EQUIPMENT_TYPE_ARMOUR, 'identificator' => $armour_object->id, 'position' => $key + 11);
                             $data['message'] .= 'e inventariada (' . $inventory->save() . ')</p>';
                         } else {
                             $data['message'] .= '<p>KAKUNA MATATA!!';
                         }
                     }
                     //Set spears
                     $position = 27;
                     $spear = Spears::model()->findByPk(1);
                     //Lanza de entrenamiento
                     foreach (Spears::getDefaultEquipment() as $key => $id) {
//.........这里部分代码省略.........
开发者ID:RubenDjOn,项目名称:medieval-jousting-tournaments,代码行数:101,代码来源:SiteController.php

示例15: EncounterSpace

<?php

$classes = ["Pokemon", "EncounterSpace", "Inventory"];
foreach ($classes as $class) {
    require_once $class . ".class.php";
}
$es = new EncounterSpace("Forest", "forest");
$es->save();
$poke = $es->findPokemon($_GET['id']);
$inv = new Inventory();
$inv->save();
$inv->addPokemon($poke);
echo "You've just caught: " . $poke->name;
echo '<hr><a href="my-inventory.php">See your inventory</a>';
开发者ID:olmobuining,项目名称:PhpPokemon,代码行数:14,代码来源:catch.php


注:本文中的Inventory::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。